operator ' is ambiguous

Started by
3 comments, last by Polymorphic OOP 19 years, 6 months ago
Hi ,any time i try using cout<< unsigned __int64value i get an operator << is ambigous. A solution would be to use printf but this is so so C like. Any ideas? [smile]
Advertisement
Update your iostreams library?

What compiler are you using?
Arguing on the internet is like running in the Special Olympics: Even if you win, you're still retarded.[How To Ask Questions|STL Programmer's Guide|Bjarne FAQ|C++ FAQ Lite|C++ Reference|MSDN]
Were you actually literally trying some statement like "cout << unsigned __int64 value;", or do you mean
unsigned __int64 value;cout << value;

?

The first won't work. At all. The second will work if your compiler is not lame. If it doesn't work, your compiler is lame. [wink]
My stuff.Shameless promotion: FreePop: The GPL god-sim.
Quote:Original post by Doc
The second will work if your compiler is not lame. If it doesn't work, your compiler is lame. [wink]
Or you are using the wrong header.
unsigned __int64 isn't a standard C++ type, therefore your compiler's headers probably do not overload << for it to work with the ostream templates. No, this doesn't mean your compiler is bad -- it's perfectly fine. You get ambiguity because an unsigned __int64 can be converted to a standard C++ type that does have an overloaded <<. For instance, usigned __int64 can be probably be implicitly converted to either an unsigned long or an unsigned int or an unsigned short or an unsigned char, all of which have an associated operator << overloaded to work with the ostream templates so it's ambiguous as to which one it should convert to. So, either overload << for unsigned __int64 to work with ostream or explicitly typecast your value to a standard C++ type which has an overloaded << to work with ostream.

This topic is closed to new replies.

Advertisement