(3)命名空间

#include <iostream>
using namespace std;

namespace a
{
	int x(1);
	void fun()
	{
		std::cout << "a" << endl;
	}
}
namespace b
{
	int x(2);
	void fun()
	{
		cout << "b" << endl;
	}
	void fun2()
	{
		cout << "c" << endl;
	}
}
using namespace b;
int main()
{
	cout << a::x << endl;
	b::fun();
	fun2();
	system("pause");
	return 0;
}

猜你喜欢

转载自blog.csdn.net/nuc_sheryl/article/details/81086652