Possible Duplicate:
Ordering of using namespace std; and includes?
I heard that it is strongly prohibited to use “using namespace xy” before “#include “. E.g.
#include <iostream>
using namespace std;
int main() {
...
}
What’s the technical reason for that? I tried following and it worked without any problems:
using namespace std;
#include <iostream>
int main() {
....
}
No, it is not strongly prohibited (otherwise it would be a compilation or preprocessing error).
The
usingkeyword puts all functions and variable into the current namespace, and it is discouraged to use it in the header files.