home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!devnull!seiko.mpd.tandem.com!rjf
- From: rjf@seiko.mpd.tandem.com (Russell Fleming)
- Newsgroups: comp.lang.c++
- Subject: Re: Simulate "Pointer to char" by an array
- Message-ID: <3223@devnull.mpd.tandem.com>
- Date: 30 Dec 92 19:53:47 GMT
- References: <1992Dec30.172241.11378@dcs.warwick.ac.uk>
- Sender: news@devnull.mpd.tandem.com
- Lines: 34
-
- In article <1992Dec30.172241.11378@dcs.warwick.ac.uk>,
- cmchan@dcs.warwick.ac.uk (C M Chan) writes:
- >
- > 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, [... DELETED ...]
-
- If I understand your question correctly, you can add a char* operator to
- the class which will return the type of pointer you are looking for.
- For example:
-
- class X {
- private:
- char str[...];
- public:
- X(void);
- ~X(void);
- operator char* (void) { return str; }
- };
-
- main ()
- {
- X x;
- char s[...];
- strcpy (s, (char *) x);
- }
-
- =================================================================
- Rusty Fleming, Software Consultant @ Tandem Computers Inc.
- email: rjf@mpd.tandem.com Austin, Texas
- voice: (512) 244 - 8390 USA
-