Paul Henderson wrote:
<suggesting avoiding using namspace std>
Oh, just better practice in many people's opinion [though I might start
an argument if I say that too strongly]. Basically, there's no point in
*having* the std namespace if you're just going to include it at global
scope everywhere, and there's a danger of symbol-name conflicts between
your code and bits of std. But it doesn't really matter :-)
Please quote some context in your message.
It is true that if you put a using directive or using declaration in
your own source file, it only affects you. As long as you understand
the issue, it's up to you whether you do it. However, the code that
sparked this discussion was a class definition, which could well reside
in a header file. If so, the argument for explicitly qualifying names
from the std namespace in preference to a using directive or
declaration should be made much more strongly.
If you put using namespace std or even using std::string in a header
file, *everyone* who includes your header file gets the namespace
pollution, whether they want it or not. This is very different from you
deciding to accept namespace pollution contained within your own source
file.
So it might be fair to say "But it doesn't really matter" if you are
talking about a source file, particularly in a toy program you are
writing for practice. But in a header file it really does matter. Don't
put using directives or using declarations in header files.
Gavin Deane