First, Why use namespaces
A large project is often done independently by a number of people, different people complete different parts, and finally combined into a complete program. Since each header file is designed by different people, it is possible to name the defined class or function in different headers with the same name, so that there is a naming conflict in the program. Not only that, it is possible that our own defined names will conflict with names in the C + + library.
The name conflict is that there are two or more entities with the same name in the same scope, in order to resolve the naming conflict, the namespace is introduced in C + +, the so-called namespace is a scope that can be defined by the user, in different scopes can define the same name of the variable, non-interference, The system can differentiate them.
Second, What is a namespace
A namespace is a memory area named by the program designer, which is separated from other global entities by specifying a number of named spatial domains and storing some global entities in each namespace, respectively.
In layman's terms, each namespace is a namespace domain, and global entities stored in the namespace domain are valid only within the domain. namespaces restrict the domain of global entities to resolve naming conflicts reasonably.
php--namespaces