c++ (using)

namespace KingGlory {
	int sunwukongID = 10;
}
void test01()
{
	int sunwukongID = 20;
	//using KingGlory::sunwukongID;//也会有二义性
	cout << sunwukongID << endl;
}
namespace LOL
{
	int sunwukongID = 30;
}
//using 编译指令
void test02()
{
	//int sunwukongID = 20;
	using namespace KingGlory;//打开房间
	using namespace LOL;//如果打开多个房间,也要避免二义性
	cout << LOL::sunwukongID << endl;
}

posted on 2021-04-21 18:00  lodger47  阅读(31)  评论(0)    收藏  举报

导航