• 0

[c++] ambiguous symbol error


Question

I have a pretty simple question, I used using namespace std; in my program and that should be able to let me use my cout and cin and other things right? But instead I get about 30 errors. saying basically error C2872:'cout' : ambiguous symbol. Anybody know why : using namespace std; doesn't work?

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

It's because you're probably mixing up the operators for cout and cin.

Cout uses << and cin uses >> :yes: Make sure you're using the correct operator, otherwise you'll get this error.

Title edited for clarity

Link to comment
Share on other sites

  • 0

namespace std; does not have anything to do with cout and cin.

Namesapces are like the title, namespaces, sort of like vistula desktops. Two different namespaces can for example contain global variables with the same names but with diff values.

What you are looking for are headers, or includes.

put this in your code.

#include <iostream>

and that should make that work ... good luck!

Link to comment
Share on other sites

  • 0
namespace std; does not have anything to do with cout and cin.

Namesapces are like the title, namespaces, sort of like vistula desktops. Two different namespaces can for example contain global variables with the same names but with diff values.

What you are looking for are headers, or includes.

put this in your code.

#include <iostream>

and that should make that work ... good luck!

No, it sort of does. It uses a different namespace than your app (which you will have one even if you don't define one), and it will give you an error. Your definition really made no sense, it's more a way of defining scope so to avoid name collisions for variables, types, classes or functions. You were somewhat right towards the end, but the beginning made no sense.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.