Home » Community » Newbie corner » Trouble with reference variable in THISBACK1
Trouble with reference variable in THISBACK1 [message #46783] |
Thu, 04 August 2016 09:17  |
Tom1
Messages: 1302 Registered: March 2007
|
Ultimate Contributor |
|
|
Hi,
I'm working with U++ 9251 on Windows 10 64-bit using MSC9, MSC10 and MSC15 in 32 bit mode. I just can't figure out what's wrong with my code. It seems the reference variables do not work as parameters in THISBACKx and the actual vector items being referenced do not get updated in the process:
#include <Core/Core.h>
using namespace Upp;
class c_t: Moveable<c_t> {
public:
int x;
int y;
c_t(){
x=99;
y=99;
}
};
class RefTest{
typedef RefTest CLASSNAME;
Vector<c_t> cv;
public:
RefTest(){}
void prepare_c(c_t &c){
c.x=1;
c.y=2;
}
void Run(){
CoWork cw;
for(int i=0;i<1;i++){
c_t &ref=cv.Add();
cw.Do(THISBACK1(prepare_c,ref));
}
cw.Finish();
for(int i=0;i<cv.GetCount();i++){
printf("%d %d\r\n",cv[i].x,cv[i].y);
}
}
};
CONSOLE_APP_MAIN{
RefTest t;
t.Run();
}
It just prints "99 99" whereas I'm expecting "1 2".
Help, anybody?
Best regards,
Tom
|
|
|
Goto Forum:
Current Time: Wed Apr 30 09:15:25 CEST 2025
Total time taken to generate the page: 0.04072 seconds
|