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