static const int flag= 10;
const int num = 10;
注解:
static修饰全局变量,表示只在本文件(private)中可见,在其他文件不可见
拓展:
为保证全局变量仅在本文件可见,C++有两种办法:
1.用static修饰
2.定义匿名空间
namespace {
const int flag = 10;
}
static const int flag= 10;
const int num = 10;
注解:
static修饰全局变量,表示只在本文件(private)中可见,在其他文件不可见
拓展:
为保证全局变量仅在本文件可见,C++有两种办法:
1.用static修饰
2.定义匿名空间
namespace {
const int flag = 10;
}