You should avoid usingnamespace std in general because it can cause problems when using different libraries
1 2 3 4 5 6 7 8 9
template < class T, class Allocator = allocator<T> >
class vector // STL vector
1 2 3 4 5 6
template < class T >
class vector // my own vector
1 2 3 4 5 6 7 8 9 10 11 12
vecor < int > x; // my own vector ( mylib.h doesn't define any namespace )
vecor < int > y; // which vector? it's ambiguous now that bot vectors can be found in the global namespace
You should particularly avoid using in header files as every other file which will #include them will get this issue
2. Why should I use that declaration in the header file?
Assuming you meant "shouldn't", it's because header files will hide the using directive, bringing the entire namespace into global scope even though you don't see that anywhere in your .cpp file. If it's a commonly used header, that might easily lead to trouble. The most common example is the clash caused by using the identifier "count".
I recommend you avoid using directives; using declarations make a lot more sense, although, personally, I would just rather use the fully qualified name.