头文件test.h中添加
extern const int a;
cpp文件test.cpp中添加
#include "test.h"
const int a = 0;
main.cpp
#include "test.h"
int main()
{
a;
}
编译时a不是一个编译时常量,main.cpp有可能先编译,此时a未定义会产生报错。
头文件test.h中添加
extern const int a;
cpp文件test.cpp中添加
#include "test.h"
const int a = 0;
main.cpp
#include "test.h"
int main()
{
a;
}
编译时a不是一个编译时常量,main.cpp有可能先编译,此时a未定义会产生报错。