I read this page.
C++ header files with no extension
And I understood that comment as saying that namespaces existed even before the introduction of the C++ standard.
So wasn't that comment saying that namespaces and the absence of file extension are not related?
However, the following comment didn't mention how namespaces were used when using cout
in iostream.h.
So my Questions are:
cout
in iostream.h?The committee voted to accept namespaces into the standard in 1993. Most compilers supported it fairly shortly after that, so for around 5 years before the standard was approved.
Headers without extensions happened around the same time, so mostly when you used iostream.h
, you just used cout << foo;
, and when you switched to iostream
, you used std::cout << foo;
.
For backward compatibility, many compilers continued to supply an iostream.h
for a while after they had iostream
. It was often something like this:
#include <iostream>
using namespace std;
This was enough for a lot of fairly simple programs to compile, but broke with some that got into the dark corners of the older library code (and honestly, not even very dark corners).
Other compilers had two completely separate libraries though, so iostream.h
contained declarations for one and iostream
for the other.