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 #27058 is a reply to message #27054] Wed, 23 June 2010 16:38 Go to previous messageGo to previous message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
I don't understand.

Option 2 is correct - ArrayCtrl doesn't overload Add(Ctrl &) (it's not even virtual), so obviously it's being called on the Ctrl base class.

Option 1 doesn't work because ArrayCtrl doesn't overload Add(Ctrl &), so the pointer signature is incorrect.

If you add the following to MyD then both options work correctly:
class MyD
	: public ArrayCtrl 
{
public:
	typedef MyD CLASSNAME;
	virtual ~MyD() {}
	
	void    Add(Ctrl& ctrl) { Ctrl::Add(ctrl); Update(); }	
};

Option 1: Calls MyD::Add
void (MyD::* mfp)(Ctrl &) = &MyD::Add; 
(md.*mfp)(l);

Option2 calls Ctrl::Add
void (Ctrl::* mfp2)(Ctrl &) = &Ctrl::Add;
(md.*mfp2)(l);


This is also possible, and perhaps most useful:
void (MyD::* mfp)(Ctrl &) = &Ctrl::Add; 


(Tested with latest SVN and MSC8)

[Updated on: Wed, 23 June 2010 16:44]

Report message to a moderator

 
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 17:36:45 CEST 2024

Total time taken to generate the page: 0.02746 seconds