I emailed Bjarne Stroustrup about this a long time ago. It wasn't in
his FAQ either. He seemed ok with "using namespace std;". He said
that the classes in the standard library are common enough that when
you see (for example) "string" you know it means "std::string". For
that reason, I think the policy on "using namespace std;" should be up
to your group's coding standard, not an absolute. *HOWEVER*, it has
been stressed on this ng many times that such a directive has no place
in a header file because it brings the entire std namespace into any
file that #includes it. IMHO this is very good advice.
I agree, this should be in the FAQ.
Kristo
With all due respect to Mr. Stroustrup, I believe this has two
distinct drawbacks:
(a) Once an implementation file has "using namespace std;" ANYWHERE
(including inside a function's definition body), it assumes that there
will never be any new names added to the standard library, or that the
code in question will never have to be recompiled at a later date when
there might very well be newer names in there;
(b) It also assumes that all names currently (i.e. at the point in
time when the code was written) defined by the standard library in
namespace std are known.
Of course, we all know that there is a std::string. But do all of you
honestly believe that you know EVERY name in namespace std? And if
not, there is always the chance that you might try to define it for
your own code. Or someone else might do it later when you aren't
around anymore.
And what about junior programmers?