home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / cplus / 19953 < prev    next >
Encoding:
Text File  |  1993-01-28  |  4.3 KB  |  111 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!digex.com!intercon!udel!bogus.sura.net!howland.reston.ans.net!spool.mu.edu!sdd.hp.com!saimiri.primate.wisc.edu!ames!ads.com!saturn!doug
  3. From: doug@monet.ads.com (Doug Morgan)
  4. Subject: Re: Question About Code In ARM
  5. In-Reply-To: maxtal@extro.ucc.su.OZ.AU's message of Tue, 26 Jan 1993 22:07:53 GMT
  6. Message-ID: <DOUG.93Jan27094938@monet.ads.com>
  7. Sender: usenet@ads.com (USENET News)
  8. Organization: Advanced Decision Systems, Mountain View, CA 94043, +1 (415)
  9.     960-7300
  10. References: <1993Jan20.014738.8501@ctp.com>
  11.     <1993Jan20.233819.24771@ucc.su.OZ.AU>
  12.     <DOUG.93Jan21151105@monet.ads.com> <1993Jan26.220753.5187@ucc.su.OZ.AU>
  13. Date: Wed, 27 Jan 1993 17:49:38 GMT
  14. Lines: 95
  15.  
  16. In article <1993Jan26.220753.5187@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
  17.    In article <DOUG.93Jan21151105@monet.ads.com> doug@monet.ads.com (Doug Morgan) writes:
  18.    >In article <1993Jan20.233819.24771@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
  19.    >   In article <1993Jan20.014738.8501@ctp.com> dchen@ctp.com (Denys Chen) writes:
  20.    >   >(In another word, can we remove ", public virtual W" ?) 
  21.    >   >                                 ^^^^^^^^^^^^^^^^^^
  22.    >
  23.    >       Depends. The requirement "you can only initialise an
  24.    >   immediate base"...
  25.    >
  26.    >... In any case, someone (I think it was Stephen Clamage) said
  27.    >the (quasi-implied) restriction has been tossed from the latest
  28.    >version of the proposed standard.
  29.  
  30.        Better not be tossed out: its an important restriction.
  31.  
  32. Tossed out was too strong.  Modified to allow mem-initialization of
  33. any virtual base class would probably be more accurate.  Here's the
  34. article I was remembering.  I think it means the restriction on being
  35. able to mem-initialize only immediate base classes is tossed out in
  36. the case of virtual base classes.
  37.  
  38. >From steve@taumet.com Mon Jan 11 20:54:30 1993
  39. >Newsgroups: comp.lang.c++
  40. >From: steve@taumet.com (Steve Clamage)
  41. >Subject: Re: Restatement: Virtual base class & reference initialisation
  42. >Organization: TauMetric Corporation
  43. >Date: Mon, 11 Jan 1993 19:02:33 GMT
  44. >
  45. >ajp@dsl.eng.cam.ac.uk (A. J. Piper) writes:
  46. >
  47. >|My original question on this did not include an example which is probably why I
  48. >|was misunderstood. The scenario is this:
  49. >| 
  50. >|class A {
  51. >|        const int& a;
  52. >|        A(const int& i) : a(i) {}
  53. >|        A() : a(0) {}
  54. >|};
  55. >| 
  56. >|class B : virtual public A {
  57. >|        B(const int &i) : A(i) {}
  58. >|};
  59. >| 
  60. >|class C : public B {
  61. >|        C(const int& i) : B(i) {}
  62. >|};
  63. >| 
  64. >|The reason I asked is that if you create an object of type C then B's
  65. >|initialisation of A is ignored and the default constructor is used instead ...
  66. >
  67. >That's correct.
  68. >
  69. >|So how do I initialise the reference ? Well cfront
  70. >|3.0.1 allows me to access the constructor of A directly from the constructor
  71. >|of C so I can write:
  72. >| 
  73. >|class C : public B {
  74. >|        C(const int& i) : B(i), A(i) {}
  75. >|};
  76. >| 
  77. >|Which solves my original question.
  78. >
  79. >Right.  This area of the language changed, and older compilers might
  80. >not work this way.  Relatively recent compilers should support this
  81. >code, and so should all future compilers.
  82. >-- 
  83. >
  84. >Steve Clamage, TauMetric Corp, steve@taumet.com
  85.  
  86.    >
  87.    >Hopefully the sections on virtual base classes for the final standard
  88.    >will be heavily edited by someone with a nack for logical expression
  89.    >in English.  Those sections are really a mess in the ARM.
  90.  
  91.        Even better, the rule for virtual base initialisation
  92.    could be improved so you dont have to init every VB in the complete
  93.    object .. a real mess when you're mixing 20 VB together.
  94.  
  95. Very much agreed.  C++ could do with a general upgrade to support
  96. large scale use of virtual base classes.  Current C++ facilities are
  97. very clumsy for handling problems much past the toy level.
  98.  
  99.    -- 
  100.    ;----------------------------------------------------------------------
  101.        JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
  102.        Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
  103.    ;------ SCIENTIFIC AND ENGINEERING SOFTWARE ---ph:  2 799 8223 --------
  104.  
  105. Doug
  106. --------------------------------------------------------------------
  107. Doug Morgan, doug@ads.com, (415) 960-7300
  108. Advanced Decision Systems (a division of Booz-Allen & Hamilton Inc.)
  109. 1500 Plymouth St., Mountain View, CA 94043-1230
  110. --------------------------------------------------------------------
  111.