是否可以声明一个变量extern constexpr
并将其定义在另一个文件中?
我试过了,但编译器给出了错误:
Declaration of
constexpr
variable 'i
' is not a definition
在.h中:
extern constexpr int i;
在.cpp中:
constexpr int i = 10;
发布于 2018-04-03 13:44:15
标准给出的一些例子:
constexpr void square(int &x); // OK: declaration
constexpr int bufsz = 1024; // OK: definition
constexpr struct pixel { // error: pixel is a type
int x;
int y;
constexpr pixel(int); // OK: declaration
};
extern constexpr int memsz; // error: not a definition
发布于 2018-04-03 15:01:38
https://stackoverflow.com/questions/-100003775
复制相似问题