我想知道是否可以在类的私有成员中声明一个数组(此时大小未知),并在类的构造函数中设置数组的大小。例如:
我想知道是否可以在类的私有成员中声明一个数组(此时大小未知),并在类的构造函数中设置数组的大小。例如:
class Test {
int a[];
public:
Test(int size);
};
Test::Test(int size) {
a[size]; // this is wrong, but what can i do here?
}
这是否可行,还是我应该使用动态数组?谢谢!