This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: std namespace no longer assumed?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]