home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!mole-end!mat
- From: mat@mole-end.matawan.nj.us
- Subject: Re: Downcasting (was: Re: run-time type checking)
- Message-ID: <1992Aug14.165432.14403@mole-end.matawan.nj.us>
- Keywords: polymorphism, RTTI, downcasts.
- Organization: :
- References: <1992Aug5.110132.8756@ucc.su.OZ.AU> <9222518.29381@mulga.cs.mu.OZ.AU>
- Date: Fri, 14 Aug 1992 16:54:32 GMT
- Lines: 36
-
- In article <9222518.29381@mulga.cs.mu.OZ.AU>, fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
- > 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;
- > > };
-
- > This is a good idea.
- > In particular, it seems that this technique much reduces the attraction of
- > the current proposal to allow downcasting, because users can achieve virtually
- > the same effect themselves - they just have to make the interface explicit.
-
- > class Derived1() {
- > ...
- > operator Derived1*() { return this; }
- > };
-
- The problem with this is that it requires explicit functions all over
- the place. It swells the interfaces (trust me, I've seen it used, even
- suggested it as the best possible in C++ today), swells the vtables, may
- thereby interefere with some language implementations, and makes the
- code brittle.
-
- But I like the idea of declarations in the derived type permitting or
- blocking an RTTI-based conversion.
- --
- (This man's opinions are his own.)
- From mole-end Mark Terribile
-
- mat@mole-end.matawan.nj.us, Somewhere in Matawan, NJ
-