一 namaspace含义
namespacede是namespace即“命名空间”,也称“名称空间” 、”名字空间”,
通过名称空间来分类,区别不同的代码功能。
二 namespace用法
#include <iostream>
namespace first
{
int a = 0;
int b = 1;
}
namespace second
{
int a = 2;
int b = 3;
}
int main()
{
std::cout << first::a << std::endl;
std::cout << second::a << std::endl;
return 0;
}
输出结果:
0
2
三 namespce在系统工程级别的代码中的使用
namespace hello {
class world
{
public:
static world* Instance();
bool hi();
.....
~world();
private:
static worldr* g_instance;
world();
};
}