Re: Why do we get ambiguity errors in c++?
James Smith <[email protected]> Wed, 11 Feb 2009 10:19:15 -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 because, you can pass an int to a function that takes a float. Conversions performed behind the scenes makes=A0 this possible, but as we see in the sum(...) functions this can also cause ambiguity when overloading functions. Conversions 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 Thanks, Jim Smith --- On Wed, 2/11/09, Harvinder <[email protected]> wrote: From: Harvinder <[email protected]> Subject: [cppug] Why do we get ambiguity errors in c++? To: [email protected] Date: Wednesday, February 11, 2009, 4:54 AM =20=20=20=20 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] =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/