mirror of
https://github.com/Light-City/CPlusPlusThings.git
synced 2026-02-04 19:14:07 +08:00
support bazel complie this project and format code.
This commit is contained in:
@@ -8,38 +8,28 @@
|
||||
|
||||
#include <iostream>
|
||||
#define isNs1 1
|
||||
//#define isGlobal 2
|
||||
// #define isGlobal 2
|
||||
using namespace std;
|
||||
void func()
|
||||
{
|
||||
cout<<"::func"<<endl;
|
||||
}
|
||||
void func() { cout << "::func" << endl; }
|
||||
|
||||
namespace ns1 {
|
||||
void func()
|
||||
{
|
||||
cout<<"ns1::func"<<endl;
|
||||
}
|
||||
}
|
||||
void func() { cout << "ns1::func" << endl; }
|
||||
} // namespace ns1
|
||||
|
||||
namespace ns2 {
|
||||
#ifdef isNs1
|
||||
using ns1::func; /// ns1中的函数
|
||||
#ifdef isNs1
|
||||
using ns1::func; /// ns1中的函数
|
||||
#elif isGlobal
|
||||
using ::func; /// 全局中的函数
|
||||
using ::func; /// 全局中的函数
|
||||
#else
|
||||
void func()
|
||||
{
|
||||
cout<<"other::func"<<endl;
|
||||
}
|
||||
void func() { cout << "other::func" << endl; }
|
||||
#endif
|
||||
}
|
||||
} // namespace ns2
|
||||
|
||||
int main()
|
||||
{
|
||||
/**
|
||||
* 这就是为什么在c++中使用了cmath而不是math.h头文件
|
||||
*/
|
||||
ns2::func(); // 会根据当前环境定义宏的不同来调用不同命名空间下的func()函数
|
||||
return 0;
|
||||
int main() {
|
||||
/**
|
||||
* 这就是为什么在c++中使用了cmath而不是math.h头文件
|
||||
*/
|
||||
ns2::func(); // 会根据当前环境定义宏的不同来调用不同命名空间下的func()函数
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user