Why std::cout instead of simply cout?

c++, iostream

Solution

It seems possible your class may have been using pre-standard C++. An easy way to tell, is to look at your old programs and check, do you see:

#include <iostream.h>

or

#include <iostream>

The former is pre-standard, and you'll be able to just say `cout` as opposed to `std::cout` without anything additional. You can get the same behavior in standard C++ by adding

using std::cout;

or

using namespace std;

Just one idea, anyway.

Problem

I get these error messages for all `cout` and `endl`: ``` main.cc:17:5: error: ‘cout’ was not declared in this scope main.cc:17:5: note: suggested alternative: /usr/include/c++/4.6/iostream:62:18: note: ‘std::cout’ ``` After following the suggestion, everything is fine. Now I am curious, why I had to do that. We used C++ in classes before, but I never had to write a `std::` before any of those commands. What might be different on this system?

Original source

Related problems