【发布时间】:2014-12-09 01:47:44
【问题描述】:
我需要一个 char * 数组定义为类的属性,并在类的构造函数中使用长度对其进行初始化。例如:
Foo.h:
class Foo{
public:
char * array[1] // declare the array here, syntax unsure
Foo(int length);
}
Foo.cpp:
Foo::Foo(int length){
array[length] // set the length of the array here, syntax unsure
}
不确定语法...我只看到了带有长度的指针数组的声明。我想知道如何先声明它,然后再设置/重新声明一个新的长度。
【问题讨论】: