home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c++:11732 comp.std.c++:989
- Newsgroups: comp.lang.c++,comp.std.c++
- Path: sparky!uunet!ftpbox!motsrd!news
- From: shang@corp.mot.com (David (Lujun) Shang)
- Subject: Re: run-time type checking (was: Re: Covariant Types in Derived Classes)
- Message-ID: <1992Jul29.162440.21848@cadsun.corp.mot.com>
- Sender: news@cadsun.corp.mot.com
- Reply-To: shang@corp.mot.com
- Organization: Motorola, Inc., Software Research and Development, Rolling Meadows, IL. 60008
- References: <1992Jul28.210755.3548@ucc.su.OZ.AU>
- Date: Wed, 29 Jul 92 16:24:40 GMT
- Lines: 43
-
- In article <1992Jul28.210755.3548@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John
- MAX Skaller) writes:
- > >
- > >> NOW: I want to demonstrate why using RTTI is WRONG in this case,
- > >> and why the Species() function is required.
- > >>
- > >Remenber, your function Species() IS JUST FOR THE PURPOSE TO PROVIDE RTTI.
- >
- > Yes. I'm not against having run-time-type information
- > available.
-
- See your original statement -- what you want to demonstrate.
-
- > >>
- > >> The demonstration is so simple, and applies so generally, I wonder
- > >> why I didnt think of it before.
- > >>
- > >> class DOG : Animal { ....
- > >> class HUND : Animal { .. // german programmer
- > >>
- > >This is never an execuse. If it is, your Species() function has the same
- > >problem:
- > >
- > > char* DOG::Species()
- > > { return "DOG"; }
- > > char* DOG::Species()
- > > { return "HOUND"; } // german programmer
- >
- > What?? The compiler catches this error: it is a duplicate
- > definition.
- >
- The class DOG can be declared as static in different modules and it is highly
- possible if an Australian and a German work for the same project that is
- separated into many different modules.
-
- > Actually, I think downcasting is OK when you already knew what the
- > type was, or could have. Then it is just a convenience. And safe.
- >
- Then we have not disagreement any more.
-
-
- David Shang
-
-