home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / cplus / 19713 < prev    next >
Encoding:
Text File  |  1993-01-21  |  1.1 KB  |  35 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!gatech!usenet.ins.cwru.edu!agate!stanford.edu!kronos.arc.nasa.gov!butch!netcomsv!netcom.com!csus.edu!borland.com!pete
  3. From: pete@borland.com (Pete Becker)
  4. Subject: Re: Calling of a parent method
  5. Message-ID: <1993Jan21.224001.18123@borland.com>
  6. Originator: pete@genghis.borland.com
  7. Sender: news@borland.com (News Admin)
  8. Organization: Borland International
  9. References: <1993Jan20.153647.25160@neptune.inf.ethz.ch>
  10. Date: Thu, 21 Jan 1993 22:40:01 GMT
  11. Lines: 22
  12.  
  13. In article <1993Jan20.153647.25160@neptune.inf.ethz.ch> mhof@iiic.ethz.ch (Markus Alexander Hof) writes:
  14. >
  15. >My question now: Is therea way to specify a call to a method of your immediate parent,
  16. >without naming him, so that is is possible to insert an intermeddiate class without
  17. >having to cchange the son
  18.  
  19.     Sure is.  Not quite as convenient as having a keyword:
  20.  
  21.     class D : public B
  22.     {
  23.     typedef B Parent;
  24.     void f();
  25.     };
  26.  
  27.     void D::f()
  28.     {
  29.     Parent::f();
  30.     }
  31.  
  32.     If you change the name of the base class you have to change the
  33. typedef, but nothing else has to be changed.
  34.     -- Pete
  35.