home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / std / cplus / 1758 < prev    next >
Encoding:
Text File  |  1992-12-12  |  2.3 KB  |  52 lines

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
  3. From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
  4. Subject: Re: Virtual base classes and mem initializers
  5. Message-ID: <1992Dec12.151420.28756@ucc.su.OZ.AU>
  6. Keywords: mem initializers, virtual base classes, multiple inheritance
  7. Sender: news@ucc.su.OZ.AU
  8. Nntp-Posting-Host: extro.ucc.su.oz.au
  9. Organization: MAXTAL P/L C/- University Computing Centre, Sydney
  10. References: <1992Dec11.165754.9910@Cadence.COM>
  11. Date: Sat, 12 Dec 1992 15:14:20 GMT
  12. Lines: 38
  13.  
  14. In article <1992Dec11.165754.9910@Cadence.COM> cox@cadence.com (Henry Cox) writes:
  15. >(I posted this last night - it did not appear on our systems, so I am
  16. >posting it a second time.  I apologize for any duplication you see.)
  17. >
  18. >I ran into an interesting situation with respect to multiple
  19. >inheritance and [initialising] virtual base classes.  
  20.  
  21. >Comments?  Suggestions?  
  22. >
  23.     Markku Sakkinen has written a paper on this issue, due to
  24. appear in the C++ Report I believe. it is generally felt
  25. that initialisation by the 'join' class should be used.
  26.     Another idea I put forward was to use the name dominance
  27. rule, but this would require the ctor initialisers to be part
  28. of the interface.
  29.  
  30.     The real question is 'why am I initialising virtual bases',
  31. and 'how do I explain that there are *different* initialisers'.
  32. It should be that if a base is initialised at all, it is initialised
  33. in only one way. This is enforced for single inheritance by
  34. only allowing initialisation of direct bases, and for virtual bases
  35. by insisting that the most derived class initialises them,
  36. even if not direct bases, so any other initialisers are unfortunately
  37. ignored.
  38.  
  39.     This phenomenon is extremely annoying when using mixins,
  40. when all the abstract base classes are virtual, and the whole lot
  41. have to be initialised in the most derived class.
  42.  
  43.     A general rule of thumb would appear to be that candidates
  44. for shared base status should never require non-default initialisation,
  45. since this is the only reasonable way to have unique initialisation.
  46.  
  47. -- 
  48. ;----------------------------------------------------------------------
  49.         JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
  50.     Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
  51. ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
  52.