home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!pipex!warwick!dcs.warwick.ac.uk!cmchan
- From: cmchan@dcs.warwick.ac.uk (C M Chan)
- Subject: Simulate "Pointer to char" by an array
- Message-ID: <1992Dec30.172241.11378@dcs.warwick.ac.uk>
- Sender: news@dcs.warwick.ac.uk (Network News)
- Nntp-Posting-Host: stone
- Organization: Department of Computer Science, Warwick University, England
- Date: Wed, 30 Dec 1992 17:22:41 GMT
- Lines: 37
-
-
- 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
-
-
-