std namespace no longer assumed?

John Love-Jensen eljay@adobe.com
Tue Jun 10 11:50:00 GMT 2003


Hi Sean,

> Is there a compiler switch to work around having to add:
> using namespace std;
> to all my source files?

I hope not!  Otherwise, some programmers may be tempted to make
non-compliant C++.

(And it appears that there isn't a GCC compiler switch to do that, anyway.)

Also, I recommend you do NOT add "using namespace std;" everywhere.
Instead, do things like "using std::cout;", where you pull into your source
code's namespace exactly (and conscientiously) the things that you are
utilizing.

For example:
#include <iostream>
  using std::cout;
  using std::cerr;
  using std::endl;
#include <string>
  using std::string;

--Eljay



More information about the Gcc-help mailing list