home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!wupost!darwin.sura.net!cs.ucf.edu!schnitzi
- From: schnitzi@cs.ucf.edu (Mark Schnitzius)
- Subject: Simple inheritance question
- Message-ID: <schnitzi.714141577@eola.cs.ucf.edu>
- Sender: news@cs.ucf.edu (News system)
- Organization: University of Central Florida
- Distribution: comp
- Date: Tue, 18 Aug 1992 12:39:37 GMT
- Lines: 23
-
- Is there any way to access the variable 'hold' in
- this example with only a pointer to the base class?
-
- class base {};
-
- class derived: public base {
- int hold;
- };
-
- main ()
- {
- derived d;
- base *p;
-
- p = &d;
-
- cout << p->hold; //DOESN'T WORK!
- }
-
- -----
- Mark Schnitzius
- schnitzi@eola.cs.ucf.edu
- Univ. of Central Florida
-