假设我有以下文件。这是无效的 C++(链接器阻塞,所以是的)还是我的语法错误?constexpr 函数的前向声明是否必须与其定义在同一个文件中?
头文件.h
extern constexpr int fun(int);
源文件
constexpr int fun(int x) { return x * 2; }
c++ constexpr c++11 c++14
c++ ×1
c++11 ×1
c++14 ×1
constexpr ×1