home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!elroy.jpl.nasa.gov!ames!data.nas.nasa.gov!taligent!apple!voder!genie!roger
- From: roger@genie.UUCP (Roger H. Scott)
- Newsgroups: comp.lang.c++
- Subject: Re: Checking the this pointer
- Message-ID: <446@genie.UUCP>
- Date: 14 Dec 92 00:32:05 GMT
- References: <92343.204152PPARSONS@ESOC.BITNET> <ByysvM.4yu@cs.uiuc.edu>
- Reply-To: roger@genie.UUCP (Roger H. Scott)
- Organization: proCASE Corporation, Santa Clara, CA
- Lines: 37
-
- In article <ByysvM.4yu@cs.uiuc.edu> pjl@cs.uiuc.edu (Paul Lucas) writes:
- >In <92343.204152PPARSONS@ESOC.BITNET> <PPARSONS@ESOC.BITNET> writes:
- >>Q: Meanwhile to people have ways round this. eg macros, function naming
- >>conventions?
- >
- >*****> Only if they see it as a problem; I, IMHO, don't any more than
- > the fact that you don't respecify virtual either.
-
- I prefer to *only* use "virtual" in the base-most class so it is clear
- when a new protocol [virtual function signature] is being added to a class.
- When I redefine a virtual function I use a fake syntactic sugar keyword
- "redefine" to document what's going on (wouldn't it be nice if you could just
- define DerivedClass::someVirtualFunction() in derived_class.c and be done
- with it, since redefining a virtual function does *not* change the class's
- interface one iota?). I also use syntactic sugar to hide the (admitedly
- very intuitive :-}) "= 0" syntax for declaring pure virtuals. E.g.,
-
- #define redefine
- #define subclass_responsibility =0
-
- class Base {
- public:
- virtual void someFunction() subclass_responsibility;
- // ...
- };
-
- class Mid : public Base {
- public:
- redefine void someFunction();
- virtual void newInClassMid();
- };
-
- class Derived : public Mid { // protocol identical to Mid's
- public:
- redefine void someFunction();
- redefine void newInClassMid();
- };
-