namespace

青春壹個敷衍的年華 提交于 2020-02-07 06:01:38
#include <iostream>
#include <cstring>
using namespace std;
namespace space1{

	int sp1_a=10;
}
namespace space2{

	int sp2_a=20;
	namespace space3{

		struct person{
			int id;
			char name[10];

		};
	}
}
int main(){
	using namespace space1;
	cout<<sp1_a<<endl;
	using namespace space2::space3;
	struct person p={1,"nihaomaz"};
	cout<<"id: "<<p.id<<"  name: "<<p.name<<endl;
	char data[10];
	
	std::strcpy(data,p.name);
	cout<<"data: "<<data<<endl;
	system("pause");
	return 0;
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!