473,394 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Why is this ambiguous?

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;
}
Dec 19 '07 #1
3 1611
On 2007-12-19 17:00:49 -0500, Tim H <th*****@gmail.comsaid:
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)

Dec 19 '07 #2
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
Dec 19 '07 #3
Pete Becker wrote:
On 2007-12-19 17:00:49 -0500, Tim H <th*****@gmail.comsaid:
>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?
Dec 20 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Alex Vinokur | last post by:
Why is it ambiguous? ------ foo.cpp ------ struct Foo { Foo operator* (Foo) { return Foo(); } Foo operator* (int) const { return Foo(); } Foo () {} Foo (int) {} };
16
by: REH | last post by:
Can some tell me why the chooses the constructor in class B over operator B in class A? Is this not ambiguous? Thanks. #include <iostream> using namespace std;
1
by: Alan Johnson | last post by:
Consider the following code, with the interesting lines numbered in comments: class A { public : bool f(int level = 1) // line 5 { return true ; }
9
by: xuatla | last post by:
compile error: test1.cpp:21: error: ISO C++ says that `T mtd::CDiffOperator::getdp(const mtd::mVector&, long int, mtd::mBCTYPE) const' and `void mtd::CDiffOperator::getdp(mtd::mVector&, const...
3
by: Lee Gillie | last post by:
I have a VS6 project which I brought into VS .NET, and all has been building fine. Then I upgraded to VS 2003 and I have one source which will no longer compile. Any clues? Compiling......
0
by: Michi Henning | last post by:
Hi, the following code produces an error on the second-last line: Interface Left Sub op() End Interface Interface Right Sub op(ByVal i As Integer)
4
by: Johnny van Cadsand | last post by:
Hi, I get the following errors when trying to build my solution: 'Exception' is ambiguous in the namespace 'System' 'EventArgs' is ambiguous in the namespace 'System' 'IDisposable' is ambiguous...
1
by: --== Alain ==-- | last post by:
Hi, Under VC++.net, if i include windows.h, and compile my application, i have several data types ambiguous, like IDataObject, IMessageFilter, IDropTarget,... so it means that they are...
7
by: rn5a | last post by:
This is the second time I am asking this question in this newsgroup since I haven't got a solution or response from anyone in my previous post & I need to resolve this issue desperately. Sorry for...
32
by: Anna Smidt | last post by:
I am having an "ambiguous call to overloaded function" error again. This is the function: int nGetProfWidth (int ncols, unsigned ProfSpec) { if ((ProfSpec & PROF_2d) == 0) return ncols;...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.