//// Created by pengshuai on 2022年3月31日.//#include <iostream>//#define isNs1 1#define isGlobal 2using namespace std;void func(){cout<<"::func"<<endl;}namespace ns1 {void func(){cout<<"ns1::func"<<endl;}}namespace ns2 {#ifdef isNs1using ns1::func; /// ns1中的函数#elif isGlobalusing ::func; /// 全局中的函数#elsevoid func(){cout<<"other::func"<<endl;}#endif}int main(){/*** 这就是为什么在c++中使用了cmath而不是math.h头文件*/// 会根据当前环境定义宏的不同来调用不同命名空间下的func()函数ns2::func();return 0;}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。