tron.thomas@verizon.net wrote:
Quote:
If I remember correctly, in one of his books, Scott Meyers suggests
putting code into a custom namespace rather, and here I might be
paraphrasing, "polluting the global namespace" with type definitions
and such.
>
Assuming this is a good idea, I'm wondering about what happens when so
many people do the following:
>
using namespace std;
>
It seems like such a statement will bring a lot of stuff into the
global namespace, and a lot of it won't be used at all. Most people
only make use of a small portion what contained in the std namespace.
>
I'm wondering if it isn't better to only declare what someone wants to
use such as:
>
using std::vector;
using std::cout;
>
What kind of difference can it make to use either approach for
promoting items for a specific namespace for use in global scope?
If "using namespace /X/" is contained within an individual translation
unit (a .cpp file) then it is a rather local "pollution" that can be
easily changed (assuming you aren't writing .cpp files that are
thousands of lines long.)
However putting using declarations or definitions in header files have a
much wider effect.