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 » U++ Library support » U++ Widgets - General questions or Mixed problems » Controls & classes design questions
Re: Controls & classes design questions [message #11089 is a reply to message #11087] Sun, 19 August 2007 11:51 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13980
Registered: November 2005
Ultimate Member
mrjt wrote on Sun, 19 August 2007 05:22

Then I must be misunderstanding something. I would be grateful if you could tell me why the following code works if virtual methods are non-moveable:
struct BaseClass
{
	BaseClass() { int1 = 1; }	
	
	int int1;
	virtual int 	GetInt() 		{ return int1; }
	virtual String 	GetString() 	{ return "A String"; }
};

struct DerivedClass : public BaseClass, public Moveable<DerivedClass>
{
	DerivedClass() { int2 = 99; }	
	
	int int2;
	virtual int 	GetInt() 		{ return int2; }
	virtual String 	GetString() 	{ return "This is a derived class"; }
};

GUI_APP_MAIN
{
	Vector<DerivedClass> v;
	
	v.Add(DerivedClass());
	v.Add(DerivedClass());
	
	for (int i = 0; i < v.GetCount(); i++)
		PromptOK(Format("Int: %d String: %s", v[i].GetInt(), v[i].GetString()));
}


James


Sure it does work - at least with GCC and MSC.

The problem is that C++ standard allows memcpy only for POD types. U++ extends this to moveable types, but that is technically violating C++ standard - such thing is undefined by standard.

Therefore we try to keep such extension as thin as possible. There is really not much practical advantage to having types with vtable moveable and in the same time, it is not that much unlikely that some compiler would implement virtual methods in a way that would not work with U++.
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Multithreading ans updating widgets
Next Topic: DropList bug when removing last item
Goto Forum:
  


Current Time: Sat May 25 13:59:19 CEST 2024

Total time taken to generate the page: 0.00448 seconds