Hi BigfootCpp,
The "using namespace..." permits to flatten a namespace in your current source code.
This is handy but then comes some "decision" (automatic decision) making when identifier collide.
Say you have a constant pi in your program and you flatten a namespace with using, ant that namespace also defines a "pi" identifier. What happens ?
The rules are clear ok but when you do that, you open your source code to possibly have that issue for any and every identifier (variable, function...).
The namespace "std" is so fondamental, that's the reason why it is so short : only three letters... that means "guyz, don't be that lazy and prefix with 5 letters" that is std::
But most importantly, when you use a "using namespace..." in a header file, you will "pollute" every header file and implementation file that will include your header.
For all of that, here are the rules I apply :
1) if an implementation file is really and exceptionnaly std:: use intensive, then I may use the "using namespace std;" on a global scope... it never happened anyway until now. But that's acceptable to me.
2) when "needed", I use the "using namespace" locally to a function... this way I never pollute my entire program and this can be handy.
1 2 3 4 5
|
void aFunction()
{
using namespace ...;
}
// here, the using namespace has no effect
|
Hope that helps ^_^