home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / cplus / 17950 < prev    next >
Encoding:
Text File  |  1992-12-14  |  1.8 KB  |  49 lines

  1. 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
  2. From: roger@genie.UUCP (Roger H. Scott)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Checking the this pointer
  5. Message-ID: <446@genie.UUCP>
  6. Date: 14 Dec 92 00:32:05 GMT
  7. References: <92343.204152PPARSONS@ESOC.BITNET> <ByysvM.4yu@cs.uiuc.edu>
  8. Reply-To: roger@genie.UUCP (Roger H. Scott)
  9. Organization: proCASE Corporation, Santa Clara, CA
  10. Lines: 37
  11.  
  12. In article <ByysvM.4yu@cs.uiuc.edu> pjl@cs.uiuc.edu (Paul Lucas) writes:
  13. >In <92343.204152PPARSONS@ESOC.BITNET> <PPARSONS@ESOC.BITNET> writes:
  14. >>Q: Meanwhile to people have ways round this. eg macros, function naming
  15. >>conventions?
  16. >
  17. >*****>    Only if they see it as a problem; I, IMHO, don't any more than
  18. >    the fact that you don't respecify virtual either.
  19.  
  20. I prefer to *only* use "virtual" in the base-most class so it is clear
  21. when a new protocol [virtual function signature] is being added to a class.
  22. When I redefine a virtual function I use a fake syntactic sugar keyword
  23. "redefine" to document what's going on (wouldn't it be nice if you could just
  24. define DerivedClass::someVirtualFunction() in derived_class.c and be done
  25. with it, since redefining a virtual function does *not* change the class's
  26. interface one iota?).  I also use syntactic sugar to hide the (admitedly
  27. very intuitive :-}) "= 0" syntax for declaring pure virtuals.  E.g.,
  28.  
  29. #define redefine
  30. #define subclass_responsibility =0
  31.  
  32. class Base {
  33. public:
  34.     virtual void someFunction() subclass_responsibility;
  35.     // ...
  36. };
  37.  
  38. class Mid : public Base {
  39. public:
  40.     redefine void someFunction();
  41.     virtual void newInClassMid();
  42. };
  43.  
  44. class Derived : public Mid { // protocol identical to Mid's
  45. public:
  46.     redefine void someFunction();
  47.     redefine void newInClassMid();
  48. };
  49.