命名空间
//命名空间
//目的:对标识符的名称进行本地化,以避免命名冲突。
//namespace关键字
//using指令
//
//#include <iostream>
//using namespace std;
//int main()
//{
// cout << "Hello World!\n";
// return 0;
//}
//#include <iostream>
//using namespace std;
//namespace onespace//第一个命名空间
//{
// void print()
// {
// cout << "执行onespace名字空间的print()函数" << endl;
// }
//}
//namespace twospace//第二个命名空间
//{
// void print()
// {
// cout << "执行twospace名字空间的print()函数" << endl;
// }
//}
//int main()
//{
// //调用第一个命名空间的print()函数
// onespace::print();
// //调用第二个命名空间的print()函数
// twospace::print();
//
// return 0;
//}
#include <iostream>
using namespace std;
namespace onespace//第一个命名空间
{
void print()
{
cout << "执行onespace名字空间的print()函数" << endl;
}
}
namespace twospace