>how come you cant use that using namespace with .h on the header files.
The old headers are typically defined like this:
Code:
// iostream.h
#ifndef __IOSTREAM_H
#define __IOSTREAM_H
#include <istream.h>
#include <ostream.h>
// ...
#endif
The new ones are slightly different:
Code:
// iostream
#ifndef __IOSTREAM
#define __IOSTREAM
#include <istream>
#include <ostream>
namespace std {
// ...
}
#endif
With the old headers you don't have to tell the compiler to look anywhere except the header itself. The new headers require you to look in the header and then in the std namespace to find what you want. The directive:
Code:
using namespace std;
tells the compiler that if the name is in the std namespace, it should be accessable without resolving the namespace manually. In other words, you can say this:
Code:
cout<<"cout from namespace std"<<endl;
instead of the manual namespace resolution:
Code:
std::cout<<"cout from namespace std"<<std::endl;
-Prelude