using namespace [namespace]
Allows you to omit the [namespace] from the fully qualified name.
For instance, if you'd want to print something to the screen, you'd need something like the following code:
std::cout << "Hello" << std::endl;
As you can see the output stream cout is referred to with its fully qualified name including the namespace std as well: std::cout.
If you are feeling lazy to type the namespace all the time you can use the using namespace std statement, which allows you to not to write only the output stream without the fully qualified name.
using namespace std;
cout << "Hello" << endl;
- There could be naming clashes (that's why there are namespaces in the first place), so you may not always be able to use a namespace in your code.
- You must not use namespace pollution, that is, apply the using namespace instruction in header files as anyone who includes this file will have the same using applied, even though it may not be desired (see point 1 above).