Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Trouble with reference variable in THISBACK1
Trouble with reference variable in THISBACK1 [message #46783] Thu, 04 August 2016 09:17 Go to previous message
Tom1
Messages: 1216
Registered: March 2007
Senior 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
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Invalid build method (.bm).
Next Topic: Accept example in Tutorial
Goto Forum:
  


Current Time: Thu May 23 09:11:51 CEST 2024

Total time taken to generate the page: 0.02074 seconds