All of the standard library definitions are inside the namespace std. That is they are not defined at global scope, so in order to use them you need to qualify them in one of the following way:
std::cout
using namespace std
using std::cout
For instance lets take this:
// declarations
int global_variable;
namespace n {
int variable2;
}
global_variable
can be access as it is:
int x;
x = global_variable;
But variable2 is not part of the global space, but part of the namespace n
.
int x;
x = variable2; // error variable2 identifier not found.
So you have to use the fully qualified name:
int x;
x = n::variable2;
As a shortcut you can write:
using namespace n;
int x;
x = variable2; // variable2 is searched in current namespace
// and in all namespaces brought in with using namespace
// Found ONLY in namespace n -> OK
or
using n::variable2; // this makes any unqualified reference to `variable2`
// to be resolved to `n::variable2`
int x;
x = variable2;
As for the header files, iostream.h
was used by many compilers before there was a standard. When the committee tried to standardize they decided to make the C++ headers extensionless in order not to break compatibility with existing code.