【发布时间】:2016-07-03 13:09:40
【问题描述】:
如果你这样做:
constexpr int LEN = 100;
LEN 变量定义为const,无需键入const 关键字。
它还有static存储,无需输入static关键字。
另一方面,如果我们在class中做同样的事情:
struct A{
constexpr static int SIZE = 100;
};
SIZE 仍然定义为const,无需输入 const 关键字,
但是SIZE 不是static 数据成员。
您需要明确输入static。否则会出现编译错误。
问题是:
需要显式输入static 的原因是什么?
【问题讨论】:
标签: c++11 language-lawyer constexpr