Quote:Original post by frubam
I'd like to ask how "using namespace std" pollutes the global space, as I'm not really sure what that[pollution] entails. I've always just been told that global initializations are bad, and I shouldn't use them, but have never been given a reason why.
Well the idea behind namespaces is that they prevent naming collisions for types and functions. The std namespace has a lot of classes and functions, some with very "generic" names like std::vector. The idea is that you don't want to simply say "give me every class and function in the standard library!" because you might get something with a name you'd like to use yourself (or that's used in a third-party library you're using). Therefore it's generally better practice to specifically state what you're using (for example "using std::vector;" or to simply put the namespace every time you use the class or function.