home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / cplus / 12307 < prev    next >
Encoding:
Internet Message Format  |  1992-08-13  |  1.4 KB

  1. Path: sparky!uunet!gatech!bloom-beacon!eru.mt.luth.se!hagbard!loglule!jbn
  2. From: jbn@lulea.trab.se (Johan Bengtsson)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Downcasting (was: Re: run-time type checking)
  5. Message-ID: <4820@holden.lulea.trab.se>
  6. Date: 13 Aug 92 10:20:49 GMT
  7. References: <9222518.29381@mulga.cs.mu.OZ.AU>
  8. Organization: Telia Research AB, Aurorum 6, 951 75 Lulea, Sweden
  9. Lines: 22
  10. X-Newsreader: Tin 1.1 PL4
  11.  
  12. maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
  13. :
  14. :There are other ways than tagged pointers to make downcasting
  15. :sound. One might be to declare the derived classes that you want
  16. :to downcast to in the base class FROM which you want to downcast:
  17. :    class Base { //....
  18. :        operator Derived1*() =0;
  19. :        operator Derived2*() =0;
  20. :    };
  21. :Now what does this do? Well, it preserved th open/closed principle
  22. :and encapsulation and the explicit interfaces principle.
  23.  
  24. What if someone using your classes decides to add a Derived3 class
  25. to which downcasting should be possible?  He must modifiy your
  26. class Base, for which he may not have source code.
  27.  
  28. Does not (help) preserve the open/closed principle at all, IMHO.
  29. -- 
  30. --------------------------------------------------------------------------
  31. | Johan Bengtsson, Telia Research AB, Aurorum 6, S-951 75 Lulea, Sweden  |
  32. | jbn@lulea.trab.se; Voice:(+46)92075471; Fax:(+46)92075490              |
  33. --------------------------------------------------------------------------
  34.