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 » Callbacks mechanism doesn't handle overloaded functions?
Re: Callbacks mechanism doesn't handle overloaded functions? [message #37484 is a reply to message #37475] Wed, 10 October 2012 21:50 Go to previous message
mirek is currently offline  mirek
Messages: 14267
Registered: November 2005
Ultimate Member
Peter wrote on Wed, 10 October 2012 15:05

Hi.

I'm a new U++ user with little experience, especially in how the framework important features work internally. That's why I'm not sure if I discovered a bug or merely a framework limitation. Here's a code snippet to demonstrate the problem:

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

class MyWindow : public TopWindow
{
	Button btn;
	
	void Fun() {PromptOK(AsString(5));}
	void Fun(int n){PromptOK(AsString(n));}
	
	public:
	typedef MyWindow CLASSNAME;
	MyWindow()
	{
		btn <<= THISBACK(Fun);
	}
};

GUI_APP_MAIN
{
	MyWindow().Run();
}


In the code above you can see two different, overloaded functions named Fun. When I try to compile it, compiler reports the following error:

error C2668: 'Upp::callback' : ambiguous call to overloaded function



Well, while it is clear that btn.WhenAction is no-parameter Callback, THISBACK(Fun) is evaluated (by compiler) independently of this fact. As such, it is indeed ambiguous whether you mean Callback with no parameters or with single parameter at this point.

Unfortunately, there is no nice solution here (C++ language limitation). You have to name your methods differently...

Mirek
 
Read Message
Read Message
Previous Topic: Need help at Linux (debian) install
Next Topic: ArrayCtrl - convert String
Goto Forum:
  


Current Time: Sun Aug 24 14:13:39 CEST 2025

Total time taken to generate the page: 0.06041 seconds