Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Why is this ambiguous?

Reply
Thread Tools

Why is this ambiguous?

 
 
Tim H
Guest
Posts: n/a
 
      12-19-2007
I understand why this is ambiguous, technically, but it seems,
frankly, retarded to consider 0 as ambiguous but 1 as not, just
because 0 == NULL.

Is there any way to defeat this that does not involve changing all
code that uses 0 as an argument to use bignum(0)?


#include <string>
using namespace std;

class bignum
{
public:
bignum(int val) {}#include <string>
using namespace std;

class bignum
{
public:
bignum(int val) {}
};

int
foo(bignum arg)
{
return 0;
}
int
foo(const string &arg)
{
return 0;
}

int
main()
{
foo("hello");
foo(1);
foo(0);

return 0;
}

};

int
foo(bignum arg)
{
return 0;
}
int
foo(const string &arg)
{
return 0;
}

int
main()
{
foo("hello");
foo(1);
foo(0);

return 0;
}
 
Reply With Quote
 
 
 
 
Pete Becker
Guest
Posts: n/a
 
      12-19-2007
On 2007-12-19 17:00:49 -0500, Tim H <(E-Mail Removed)> said:

> I understand why this is ambiguous, technically, but it seems,
> frankly, retarded to consider 0 as ambiguous but 1 as not, just
> because 0 == NULL.
>


Please look up the definition of "retarded" so that you can use it
correctly. This usage is offensive to people who are retarded.

--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      12-19-2007
Tim H wrote:
> I understand why this is ambiguous, technically, but it seems,
> frankly, retarded to consider 0 as ambiguous but 1 as not, just
> because 0 == NULL.


Well, everybody is free to have their own impressions of anything.

> Is there any way to defeat this that does not involve changing all
> code that uses 0 as an argument to use bignum(0)?


No, and why should there be? Imagine the code without your 'bignum'
where no 'foo(1)' can exist. 'foo(0)' compiles OK (never mind that
it doesn't work, what if it does?) Now, imagine that by adding
an unrelated 'bignum' class and a function overload, you would be
able to change the behaviour of some unrelated code without even
a warning, if it were allowed.

You need to replace all 'foo(0)' with 'foo(bignum(0))', I guess.

>
>
> #include <string>
> using namespace std;
>
> class bignum
> {
> public:
> bignum(int val) {}#include <string>
> using namespace std;
>
> class bignum
> {
> public:
> bignum(int val) {}
> };
>
> int
> foo(bignum arg)
> {
> return 0;
> }
> int
> foo(const string &arg)
> {
> return 0;
> }
>
> int
> main()
> {
> foo("hello");
> foo(1);
> foo(0);
>
> return 0;
> }
>
> };
>
> int
> foo(bignum arg)
> {
> return 0;
> }
> int
> foo(const string &arg)
> {
> return 0;
> }
>
> int
> main()
> {
> foo("hello");
> foo(1);
> foo(0);
>
> return 0;
> }


V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


 
Reply With Quote
 
anon
Guest
Posts: n/a
 
      12-20-2007
Pete Becker wrote:
> On 2007-12-19 17:00:49 -0500, Tim H <(E-Mail Removed)> said:
>
>> I understand why this is ambiguous, technically, but it seems,
>> frankly, retarded to consider 0 as ambiguous but 1 as not, just
>> because 0 == NULL.
>>

>
> Please look up the definition of "retarded" so that you can use it
> correctly. This usage is offensive to people who are retarded.
>


How do you know?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
why why why why why Mr. SweatyFinger ASP .Net 4 12-21-2006 01:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
Cisco 2611 and Cisco 1721 : Why , why , why ????? sam@nospam.org Cisco 10 05-01-2005 08:49 AM
Why, why, why??? =?Utf-8?B?VGltOjouLg==?= ASP .Net 6 01-27-2005 03:35 PM
Why Why Why You HAVE NO IDEA MCSE 31 04-24-2004 06:40 PM



Advertisments