关于类中静态常量的声明和定义
class Test {
public:
static const int const_value = 1;
};
static const int const_value = 1
为类中的声明式,而非定义式。
定义与声明
定义即为一个声明,它定义有声明引入的实体。除了下述,每个声明都是一个定义:
- 无函数体的函数声明
int f(int); // declares, but doesn't define f
- 有
extern
存储类说明符,或语言链接性说明符( 例如extern "C"
) 且 没有初始化器的声明extern const int a; // declares, but doesn't define a extern const int b = 1; // defines b
- 类定义中的
non-inline (since C+&