我有一个类,我想和值0,1,3,7,15一些位掩码的阵列,...声明在C++中const的整数
所以基本上我要声明一个数组例如:
class A{
const int masks[] = {0,1,3,5,7,....}
}
但编译器会一直抱怨。
我想:
static const int masks[] = {0,1...}
static const int masks[9]; // then initializing inside the constructor
如何可以做到这一点任何想法?
谢谢!
这种方法的问题是,我希望能够使用它像一个数组。例如调用一个值掩码[3]并获得一个特定的掩码。 – 2009-05-30 01:53:20
好的。了解。 你想用litbs答案,那就是这样做的方法。 – EvilTeach 2009-05-30 02:21:01