home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11824 < prev    next >
Encoding:
Internet Message Format  |  1992-07-30  |  1.5 KB

  1. Xref: sparky comp.lang.c++:11824 comp.std.c++:1000
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!think.com!barmar
  3. From: barmar@think.com (Barry Margolin)
  4. Newsgroups: comp.lang.c++,comp.std.c++
  5. Subject: Re: Downcasting and mortal sin (was run-time type checking)
  6. Date: 30 Jul 1992 22:51:13 GMT
  7. Organization: Thinking Machines Corporation, Cambridge MA, USA
  8. Lines: 24
  9. Message-ID: <159rp1INNcjc@early-bird.think.com>
  10. References: <2A75806A.826A@tct.com> <1992Jul29.164343.21959@cadsun.corp.mot.com> <2A784613.34A4@tct.com>
  11. NNTP-Posting-Host: telecaster.think.com
  12.  
  13. In article <2A784613.34A4@tct.com> chip@tct.com (Chip Salzenberg) writes:
  14. >According to shang@corp.mot.com:
  15. >>In article <2A75806A.826A@tct.com> chip@tct.com (Chip Salzenberg) writes:
  16. >>> virtual boolean Animal::can_mate_with(const Animal&);
  17. >>
  18. >>I'm interested in the implementation of your "can_mate_with" in a derived  
  19. >>class. Whould you show me how it is done without RTTI?
  20.  
  21. [Shang then puts a few other restrictions on him.]
  22.  
  23. >No, not okay.  I do not program with one hand tied behind my back.
  24. >The complete language is always at my disposal.
  25.  
  26. OK, let me rephrase shang's challenge (and beat maxtal to the punch):
  27.  
  28. How can you implement can_mate_with() in such a way that the open/closed
  29. principle is maintained?  This requires that you be able to add new derived
  30. classes without having to modify the base class definition (which may be
  31. shrink-wrapped, so the source is not available for modification).
  32. -- 
  33. Barry Margolin
  34. System Manager, Thinking Machines Corp.
  35.  
  36. barmar@think.com          {uunet,harvard}!think!barmar
  37.