Topic: Array in class
Author: cmchan@dcs.warwick.ac.uk (C M Chan)
Date: Wed, 30 Dec 1992 17:18:46 GMT Raw View
Hi out there,
I am sorry if this is faq for this newsgroup. Here is my question:
How can I simulate "pointer to char" by an array in a class whose size will be delayed to be
defined at run time?
For example,
class X {
private:
char string[ ]; /* not define size of the array */
^^^^^^^^
public:
X(int);
...............
};
X::X(int size) {
string[size]; /* define size of string array now */
strcpy(string, "Hello");
}
Any pointer to this problem will be greatly appreciated. Thanks in advance.
--
C M CHAN cmchan@dcs.warwick.ac.uk