class A
{
enum { SIZE1 = 100, SIZE2 = 200}; // 枚举常量
int array1[SIZE1];
int array2[SIZE2];
};
第一种方法,使用枚举常量
class A
{
static const int SIZE=100;
int array[SIZE];
}
第二种方法,使用静态变量
注意需要和类声明中的常量比较以及和#define中定义的常量比较
class A
{
const int size; //只能在够照函数中初始化。每个对象中的数值不一样
}