why no ambiguity error in code?

Joined
Feb 12, 2008
Messages
108
Reaction score
0
Hello everyone,


Any ideas why there is no ambiguity issues in the code? Which myfunc is called?

The code can pass compile and link in Visual Studio 2008 without any warning messages. The output is 100.

Code:
int myfunc (int& a) {return 100;}

int myfunc (const int& a) {return 200;}

int main()
{
	int a = 1;
	int& ra = a;
	int rtn;
	rtn = myfunc (ra); // call which myfunc? output 100
	return 0;
}


thanks in advance,
George
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top