1 命名空间
1.1 意义和用法
为了区分不同库中相同名称的函数、类、变量,使用了命名空间即定义了上下文。
#include
namespace first_space{
void func() {
std::cout << "first_space:func()"<<std::endl;
}
}
namespace second_space{
void func() {
std::cout << "second_space:func()"<<std::endl;
}
}
int main(){
first_space::func();
second_space::func();
return 0;
}
1.2 使用标准库
- 1,using directive
eg:using namespace std;
- 2,using declaration
eg:using std::cout;