The program can not have two function name of the same, but the program is bigger, it is likely to cause two of the same name of the same parameter functions, which will lead to ambiguity and error.
So make a namespace, you can do as long as it is a different space can have the same name as the same parameter function, so that other people to do, you can not look at the previous write what function name, and as long as a new space, you can freely write function name. This makes it easier to maintain the program! This is used in a lot of PHP, and enhanced the use of namespaces, such as: There are many hierarchical namespaces in TP5, the principle is the same.
#include <iostream>
#include <stdlib.h>
int main () {
Std::cout << "inspired programming-c++" << Std::endl;
system("pause");return 0;
}
In the previous C language, there was no std:: These modifications, why?
Because it is a namespace, in this namespace, you can not have a touch of the same function;
C + + is designed to be able to develop larger programs, so it is likely to create a touch of the same function, while increasing the development hassles and maintenance hassles of subsequent participants. So C + + is made up of multiple spaces.
It's like there are multiple universes that don't interfere with each other.
So C + + has a namespace, and STD is the space name; To use something inside a space, you have to indicate which namespace it is.
But every use to write a space name, and a little trouble.
So it provides a simplified approach:
Specify which space to use first.
#include <iostream>
#include <stdlib.h>
using namespace Std;
int main () {
cout << "inspired programming-c++" << Endl;
system("pause");return 0;
}
Same effect
The practical significance of C + + namespaces