#include<iostream>
using namespace std;
namespace A
{
void a(void)//内部实现
{
cout<<"A::a()runing\n";
}
}
namespace B
{
void a(void);//内部定义
}
void B::a()//外部实现
{
cout<<"B::a()runing\n";
}
int main(void)
{
A::a();
B::a();
using A::a;
a();
using namespace B;
//这时候不能直接a()了,可能能运行,但是不清楚
return 0;
}
运行效果:
A::a()runing
B::a()runing
A::a()runing
--------------------------------
Process exited after 0.08249 seconds with return value 0
请按任意键继续. . .
知识来源于《C++ Primer Plus(第6版)中文版》第9张 内存模型和名称空间