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 » Developing U++ » U++ Developers corner » using Ctrl::Add; required for templates / overloaded virtual functions
Re: using Ctrl::Add; required for templates / overloaded virtual functions [message #27069 is a reply to message #27059] Thu, 24 June 2010 10:51 Go to previous messageGo to previous message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
I see your problem. I think you may have run up against the limit's of the C++ compiler there. Congratulations Smile

Of course the real problem is the manner used for overloading the Add(Ctrl &) method. If a method is going to be overloaded it should be done properly. For instance, this code works exactly as you would like:

struct Base {
	int result;
	virtual void Add(Ctrl &) { result = 1; }
};

struct Mid : public Base{
	virtual void Add(Ctrl &) { result = 2; }
	void Add(int)			{ result = 4; }
};

struct Top : public Mid{
	void Nothing()  { result = 0; }
};


GUI_APP_MAIN
{
	Label l;
	Top md;
	
	//option 1: << desired >>
	void (Top::* mfp)(Ctrl &) = &Top::Add;
	(md.*mfp)(l);
}

The function pointer calls Mid::Add(Ctrl &).

So either the Ctrls that overload Add(Ctrl &) should be changed (surely they can use ChildAdded?) or Add(Ctrl &) should be made virtual.
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Splitting debs into two parts
Next Topic: is there U++ coding style reference?
Goto Forum:
  


Current Time: Thu May 16 07:42:00 CEST 2024

Total time taken to generate the page: 0.02968 seconds