楼上的,不知你自己测试过没有,如果ma不为CONST类型或宏定义,就不可能通过编译!! C编译器不允许定义大小不定的数组。 但可通过动态内存分配实现。如, C : int *pBuffer = remalloc() WIN16: GlobalAlloc()/GlobalReAlloc() WIN32: HeapAlloc()/globalReAlloc()
有没有其他方法了?关键是之前的数据不能丢失。 例如:class person {public: CString name; long age; } person *persons[0]=new person; persons[0].name="wang"; persons[0].age=32; 这时候要在数组里再加一个人persons[1],我该如何做而不失去persons[0]的资料?
C编译器不允许定义大小不定的数组。
但可通过动态内存分配实现。如,
C : int *pBuffer = remalloc()
WIN16: GlobalAlloc()/GlobalReAlloc()
WIN32: HeapAlloc()/globalReAlloc()
例如:class person
{public:
CString name;
long age;
}
person *persons[0]=new person;
persons[0].name="wang";
persons[0].age=32;
这时候要在数组里再加一个人persons[1],我该如何做而不失去persons[0]的资料?