Why is this ambiguous?

Discussion in 'C++' started by Tim H, Dec 19, 2007.

  1. Tim H

    Tim H Guest

    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;
    }
    Tim H, Dec 19, 2007
    #1
    1. Advertising

  2. Tim H

    Pete Becker Guest

    On 2007-12-19 17:00:49 -0500, Tim H <> 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)
    Pete Becker, Dec 19, 2007
    #2
    1. Advertising

  3. 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
    Victor Bazarov, Dec 19, 2007
    #3
  4. Tim H

    anon Guest

    Pete Becker wrote:
    > On 2007-12-19 17:00:49 -0500, Tim H <> 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?
    anon, Dec 20, 2007
    #4
    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. sks_cpp
    Replies:
    8
    Views:
    335
    tom_usenet
    Aug 26, 2003
  2. REH
    Replies:
    16
    Views:
    657
    Marcelo Pinto
    Mar 31, 2005
  3. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    851
    Mark Rae
    Dec 21, 2006
  4. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,733
    Smokey Grindel
    Dec 2, 2006
  5. a eriksson
    Replies:
    1
    Views:
    288
    Victor Bazarov
    Aug 9, 2005
Loading...

Share This Page