![]() |
|
#1
|
|||
|
|||
Ambiguous operatorI have a build error that says operator << is ambiguous what does it mean by saying to ambiguous??
here is the code i have in that specific line cout << fixed << showpoint << setprecision(2); |
|
#2
|
|||
|
|||
|
Quote:
You may have to indicate that you are using cout from the std namespace. Don't know what I mean? Lots of older books (and some current ones) and lots of tutorials don't mention this because pre-standard C++ didn't have such things. Nowadays, your program should look something like: CPP / C++ / C Code:
Later, when you learn about namespaces, you may want to do it differently, but for now you can consider the "using namespace std;" to be an idiom: just do it. Regards, Dave |
|
#3
|
|||
|
|||
reply to ambigious operatori know the namesspace std; thing and i have it at the top and its still telling me that in that one line for some reason in that same code
|
|
#4
|
|||
|
|||
|
Quote:
How can I guess what your problem is? My first guess didn't help. Maybe you should show us the code??????????????? You might also mention what operating system and what compiler you are using. Regards, Dave |
|
#5
|
||||
|
||||
|
The << operator is ambiguous to what you are displaying, which is nothing. You set some flags, but you never display any data. You should probably set the flags and display the data all in one statement. You set the showpoint flag, but to show the point in what number? You set the setprecision flag, but to show 2 points of precision in what number? I am pretty sure that when you set flags, you also have to display something!
__________________
-Aaron |
|
#6
|
|||
|
|||
|
Quote:
Not true. Compile and execute the following: CPP / C++ / C Code:
What do you get: nothing. (No compile errors, no output from the progam, no hits, no runs, no men left on base. What you don't see is what you don't get.) Then uncomment the commented lines and run again. What do you get? Just about what you expected, right? Since the original poster still hasn't shown us what he is trying to do, I don't see how we can guess what his problem is. His problem is not in the line that he abstracted for us. Hint to all users: when the compiler says there is an error on a particular line and that line looks OK, then you should look at lines before the indicated one. Hint to all people requestinghelp: show us what you have, what you expected to get and what you got (source code with detailed error messages). Regards, Dave |
|
#7
|
||||
|
||||
|
I am all for your suggestion, Dave, but in this particular case the "error" might be in the line provided by the poster; please take a look at my post here, where I bitch about not being able to use the fixed modifier with some compilers
However, I think that some info would be appropiate - like the compiler used on the code sample. I hope this is the annoying "bug" - if not, we'll have to dig deeper ![]() Kind regards, Luci __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
|
#8
|
|||
|
|||
|
Quote:
You know, it was really wrong of me (and, more than a little, silly) to suggest that the code that I posted would work with every compiler everywhere. What I should have done was to report that it works with my compilers, and suggest that people who think that there might be problems with this kind of stuff simplify their programs to a single line in main() and see if their compilers complained. Thanks for helping to set me back on the path to the light. Regards, Dave |
|
#9
|
||||
|
||||
|
Quote:
I wasn't talking about your code, I was talking about the (original) poster's code; he is the one who has a problem which needs solving, not you. There is no need to get all offensive about this, I guess I didn't make myself clear (as usual) Quote:
I was actually backing up your request: Quote:
Regards, Luci __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
|
#10
|
|||
|
|||
|
Quote:
I didn't think you were being unkind to me; I just wanted to try to let people know that I realize that my previous post was too abrupt and a little snotty. The problem is that it's kind of hard to take back that kind of impression, but I wish I could. Oh, well... Regards, Dave |
Recent GIDBlog
2nd Week of IA Training by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| or operator | Krc784 | CPP / C++ Forum | 1 | 04-Nov-2004 14:43 |
| Circular Linked Queue Copy Constructor and Assignment Operator Not Working? | wc3promet | CPP / C++ Forum | 0 | 17-Oct-2004 07:55 |
| operator overloading | hyapici | CPP / C++ Forum | 2 | 18-Feb-2004 19:37 |
| char to operator | calculus87 | CPP / C++ Forum | 3 | 04-Sep-2003 10:05 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The