home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / cplus / 12497 < prev    next >
Encoding:
Text File  |  1992-08-18  |  682 b   |  35 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!wupost!darwin.sura.net!cs.ucf.edu!schnitzi
  3. From: schnitzi@cs.ucf.edu (Mark Schnitzius)
  4. Subject: Simple inheritance question
  5. Message-ID: <schnitzi.714141577@eola.cs.ucf.edu>
  6. Sender: news@cs.ucf.edu (News system)
  7. Organization: University of Central Florida
  8. Distribution: comp
  9. Date: Tue, 18 Aug 1992 12:39:37 GMT
  10. Lines: 23
  11.  
  12. Is there any way to access the variable 'hold' in
  13. this example with only a pointer to the base class?
  14.  
  15. class base {};
  16.  
  17. class derived: public base {
  18.     int hold;
  19. };
  20.  
  21. main ()
  22. {
  23.     derived d;
  24.     base *p;
  25.  
  26.     p = &d;
  27.  
  28.     cout << p->hold;  //DOESN'T WORK!
  29. }
  30.  
  31. -----
  32. Mark Schnitzius
  33. schnitzi@eola.cs.ucf.edu
  34. Univ. of Central Florida
  35.