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 #27070 is a reply to message #27069] Thu, 24 June 2010 12:18 Go to previous messageGo to previous message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
hi mrjt,

sure this one works, because Mid offers own Add(Ctrl&) *additionally* and so does my app with the Ctrls that either *dont* have own Add() overloads at all or have additional override Add(Ctrl&) properly (virtual or not, no matter), but it does not work with those only having incompatible Add() overloads.

just comment out Mid::Add(Ctrl&) and leave only Add(int) in Mid...boom.

i dont even need to access it at Top level (this would represent my template class, Mid is a CtrlLib Ctrl, Base is Ctrl implementation, thanks for breaking this one down Smile, so Top can go...

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

struct Midd : public Base{
	//virtual void Add(Ctrl &) { result = 2; } //EITHER this, virtual or not, no metter
	using Base::Add; //OR this, saves compilation preserving complete Add overloads pool for compiler
	void Add(int)			{ result = 4; }
	void Nothing()   { result = 10; }
};

GUI_APP_MAIN
{
	Label l;
	Midd md;
	
	//option 1: << desired >>
	void (Midd::* mfp)(Ctrl &) = &Midd::Add; //problems even if Mid, not only Top
	(md.*mfp)(l);
}


i think this is more of a coding guideline, trying to sum up:

option 1:
when overloading (not overriding) a public virtuel base class function, be sure to have a proper override for it as well (maybe just calling base function)
or place a "using" statement to help compiler keep at least the public fnctions pool complete througout the hierarchy.

option 2:
use different function names
 
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:25:32 CEST 2024

Total time taken to generate the page: 0.03025 seconds