在VC++中,当我需要指定一个绑定类成员变量的数组时,我这样做:
class Class {
private:
static const int numberOfColors = 16;
COLORREF colors[numberOfColors];
};
Run Code Online (Sandbox Code Playgroud)
(请不要告诉我在这里使用std :: vector)
这样我就有了一个常量,可以用作数组绑定,稍后在类代码中指定循环语句约束,同时在其他任何地方都不可见.
问题是static const int成员变量的这种用法是仅由VC++允许还是其他广泛编译器通常允许的?