Re: Why do we get ambiguity errors in c++?

James Smith <[email protected]> Wed, 11 Feb 2009 09:55:34 -0800 (PST)
Newsgroups gmane.comp.programming.cppug
Message-ID <[email protected]>
Hi,

There's a conversion of the data-types so, the compiler gets confused becau=
se, you can pass an int to a function that takes a float. Conversions perfo=
rmed behind the scenes makes=A0 this possible, but as we see in the sum(...=
) functions this can also cause ambiguity when overloading functions. Conve=
rsions between arrays and pointers can cause the same type of problems.=20

The function call can be made using : sum(9,(float)9.0);

I hope this was helpful.

Thanks,
Jim Smith



--- On Wed, 2/11/09, manish gupta &lt;[email protected]> wrote:
From: manish gupta <[email protected]>
Subject: Re: [cppug] Why do we get ambiguity errors in c++?
To: [email protected]
Date: Wednesday, February 11, 2009, 8:27 AM











=20=20=20=20
            I think, by standard you can not overload a function with premi=
tive data types.



Thanks,



Manish.



"Don't Limit Your Challenges.. .Challenge Your Limits"



:)



--- On Wed, 11/2/09, Harvinder <me_harvinder@ yahoo.com> wrote:

From: Harvinder <me_harvinder@ yahoo.com>

Subject: [cppug] Why do we get ambiguity errors in c++?

To: cppug@yahoogroups. com

Date: Wednesday, 11 February, 2009, 3:24 PM



Hi everyone can anyone tell me



if i give=20



int sum(int,int) ;



int sum(float,int) ;



int sum(float,float) ;



int sum(int,float) ;



prototypes in a pgm and give a call to sum(2,3.4);



Then an ambiguity error comes between sum(int,int) and sum(int,float) ;



WHY???



Add more friends to your messenger and enjoy! Go to http://messenger. yahoo=
.com/ invite/



[Non-text portions of this message have been removed]



=09

=09=20

=09

=09



=09



=09

=09



Connect with friends all over the world. Get Yahoo! India Messenger at http=
://in.messenger .yahoo.com/ ?wm=3Dn/



[Non-text portions of this message have been removed]




=20

=20=20=20=20=20=20

=20=20=20=20

=20=20=20=20=20=20=20=20=20=20=20
=20=20
=20=20=20=20
=09
=09=20
=09
=09








=09


=09
=09


=20=20=20=20=20=20

[Non-text portions of this message have been removed]



------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/cppug/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/cppug/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[email protected]=20
    mailto:[email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/