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;
} 3 1635
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)
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
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? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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) {}
};
|
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;
|
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 ; }
|
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 mtd::mVector&,
mtd::mBCTYPE) const'
are ambiguous even though the worst conversion for the former is better
than the worst conversion for the latter
|
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...
DotNetManagedExport.cpp
C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\atlmfc\include\atlcom.h(5529) : error C2872: 'CONNECTDATA' :
ambiguous symbol
could be 'C:\Program Files\Microsoft Visual Studio .NET
| |
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)
|
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 in the namespace 'System'
I know it has something to do with double references, but i can't find
anything... I think it's weird because it's in the namespace 'System'
|
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 defined in windows.h but also in some other
namespaces.
how can i do to still have my windows.h included and avoiding ambiguous
|
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 the double
post but I just didn't have any other option other than re-posting the
same question in this newsgroup.
Consider the following code in a VB class file:
Namespace LoginUserFetchDB
Public Class ZForZebra : Inherits SoapHeader
|
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;
return int(sqrt(ncols)); //HERE THE ERROR IS THROWN
}
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |