通过命名空间提高复用性
#include
using namespace std;
namespace AA
{
int a = 100;
}
namespace BB
{
int a = 200;
}
int main()
{
cout << AA::a << endl;
cout << BB::a << endl;
system("pause");
return 0;
}
#include
using namespace std;
namespace AA
{
int nAge = 20;
void Show()
{
cout << “AA::Show” << endl;
}
}
namespace BB
{
int nAge = 30;
void Show()
{
cout << “BB::Show” << endl;
}
}
int main()
{
using namespace AA;
cout << nAge << endl;
Show();
system("pause");
return 0;
}