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