说明
C++中为了避免名字定义冲突,特别引入了 名字空间的定义,即 namespace
理解
相当于参见奥运的各个国家代表队,在介绍队员时,都要加上国家名
比如:介绍 史珍香 选手,要说:新加坡 史珍香,因为 中国、香港、台湾可能也有同名的 史珍香,不加国籍,搞不清楚
使用
方式一
#include<iostream>
using namespace std;
int main(){
cout<<"hello world" << endl;
}
方式二
#include<iostream>
int main(){
std::cout<<"hello world" << std::endl;
}
方式三
#include<iostream>
using std::cout;
using std::endl;
int main(){
cout<<"hello world" << endl;
}