std is used with vector, string,list,etc.... so putting std:: everywhere is not very elegantA standard C++ rule, that's in almost every C++ style guide I've ever read is: Never use a "using namespace" statement globally in a header.
It pollutes the global namespace in the same way that #defines do, which is something that namespaces were designed to avoid.
e.g. this is the problem with defines:
#include "windows.h"
#include <algorithm>
int a = 2, b = 4;
int c = std::max( a, b );//compile error - windows contains a #define max line!!!
Now, namespaces solve these kinds of problems for us.
Here is some perfectly valid code:
#include <queue>
class queue{};
queue q;//makes my queue, not a std::queue
std::queue<int> q2;//makes a std::queue
Now, if we include a header that has rudely used "using namespace" inside it:#include "Adaline.h" // includes "using namespace std;"
#include <queue>
class queue{};
queue q; // compile error? This code was fine a minute ago?!! thanks Adaline ;)
std::queue<int> q2;
If you really do want to use "using namespace" in a header, then you must at least always wrap it in your own namespace, e.g.
//Adaline.h
#include <queue>
namespace adaline
{
using namespace std;//ok, you've only polluted your own namespace
}
Isn't it a bad idea to call a class 'string' anyway ?The concept extends beyond the [font="Courier New"]std[/font] namespace.
Maybe I'm using two different bits of C++ middleware that both define a Vector3 type? If I using-namespace'd them, I'd get conflicts between the two libraries.