namespace Jill{
double bucket(double n){...}
double fetch;
struct Hill{..};
}
char fetch;//全局作用域
int main(){
using namespace Jill;//包含Jill作用域
Hill Thrill; //Jill作用域中的thrill
double water= bucket(2);
double fetch; //局部变量,覆盖Jill::fetch;
cin>>fetch; //局部变量fetch
cin>>::fetch; //全局作用域fetch;
cin>>Jill::fetch; //Jill::fetch;
...
}
int foom{
Hill top; //非法,没有引入作用域Jill
Jill::Hill crest;//合法
}
2.namespace的其他特性
namespace elements{
namespace fire{
int flame;
...
}
}
elements::fire::flame;//引用
using namespace elemets::fire;
namespace myth{
using Jill::fetch;
using namespace elements;
using std::cout;
using std::cin;
}
using namespace myth;
cin>>fetch;//std::cin与Jill::fetch
别名:
namespace MEF=myth::elemts::fire;//MEF是别名
using MEF::flame;
标签:作用域,namespace,cin,空间,Jill,命名,using,fetch
From: https://www.cnblogs.com/zhongta/p/18328159