c++:: Using namespace std; What does that mean?
Namespaces in C++ are used to define a scope and allows us to group global classes, functions and/or objects into one group.
When you use using namespace std;
you are instructing C++ compiler to use the standard C++ library. If you don’t give this instruction, then you will have to use std::
, each time you use a standard C++ function/entity.
Have a look at the following example, which is very straight forward.
|
|
If you are not using namespace in the above example, you will have to use std:: everywhere you use cout, like the following.
|
|
More about namespaces in C++ #
Namespaces allow you to group different entities together. You may create your own namespaces for grouping your entities, and access them the same way you did for ‘std’ namespace.
|
|
You may also use using namespace
with your custom namespces.
|
|
Warning: If you use namepaces that have same entities grouped in it, then it will result in ambiguity error.