why no ambiguity error in code?

Discussion in 'C Programming' started by George2, Feb 27, 2008.

  1. George2

    George2

    Joined:
    Feb 12, 2008
    Messages:
    108
    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
     
    George2, Feb 27, 2008
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andy
    Replies:
    5
    Views:
    488
    Ron Natalie
    Jan 23, 2005
  2. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    978
    Mark Rae
    Dec 21, 2006
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,221
    Smokey Grindel
    Dec 2, 2006
  4. subramanian100in@yahoo.com, India

    why no ambiguity error generated

    subramanian100in@yahoo.com, India, Dec 3, 2007, in forum: C++
    Replies:
    12
    Views:
    591
    Abhishek Padmanabh
    Dec 6, 2007
  5. abendstund@gmail.com
    Replies:
    7
    Views:
    480
    abendstund@gmail.com
    Jun 6, 2008
Loading...

Share This Page