【发布时间】:2012-12-15 20:13:01
【问题描述】:
我想在Foo 类中将static const std::vector 初始化为{0, 1, 2, 3, ..., n},其中n 在编译时基于下面enum 中Last 的值是已知的。目标是让Foo::all 包含Fruit 枚举的所有值。
在foo.h:
enum Fruit { Apple, Orange, Banana, ..., Last };
class Foo {
public:
static const vector<int> all;
};
在foo.cpp:
// initialization of Foo::all goes here.
【问题讨论】:
标签: c++ vector static initialization constants