home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- 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
- From: doug@monet.ads.com (Doug Morgan)
- Subject: Re: Question About Code In ARM
- In-Reply-To: maxtal@extro.ucc.su.OZ.AU's message of Tue, 26 Jan 1993 22:07:53 GMT
- Message-ID: <DOUG.93Jan27094938@monet.ads.com>
- Sender: usenet@ads.com (USENET News)
- Organization: Advanced Decision Systems, Mountain View, CA 94043, +1 (415)
- 960-7300
- References: <1993Jan20.014738.8501@ctp.com>
- <1993Jan20.233819.24771@ucc.su.OZ.AU>
- <DOUG.93Jan21151105@monet.ads.com> <1993Jan26.220753.5187@ucc.su.OZ.AU>
- Date: Wed, 27 Jan 1993 17:49:38 GMT
- Lines: 95
-
- In article <1993Jan26.220753.5187@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
- In article <DOUG.93Jan21151105@monet.ads.com> doug@monet.ads.com (Doug Morgan) writes:
- >In article <1993Jan20.233819.24771@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
- > In article <1993Jan20.014738.8501@ctp.com> dchen@ctp.com (Denys Chen) writes:
- > >(In another word, can we remove ", public virtual W" ?)
- > > ^^^^^^^^^^^^^^^^^^
- >
- > Depends. The requirement "you can only initialise an
- > immediate base"...
- >
- >... In any case, someone (I think it was Stephen Clamage) said
- >the (quasi-implied) restriction has been tossed from the latest
- >version of the proposed standard.
-
- Better not be tossed out: its an important restriction.
-
- Tossed out was too strong. Modified to allow mem-initialization of
- any virtual base class would probably be more accurate. Here's the
- article I was remembering. I think it means the restriction on being
- able to mem-initialize only immediate base classes is tossed out in
- the case of virtual base classes.
-
- >From steve@taumet.com Mon Jan 11 20:54:30 1993
- >Newsgroups: comp.lang.c++
- >From: steve@taumet.com (Steve Clamage)
- >Subject: Re: Restatement: Virtual base class & reference initialisation
- >Organization: TauMetric Corporation
- >Date: Mon, 11 Jan 1993 19:02:33 GMT
- >
- >ajp@dsl.eng.cam.ac.uk (A. J. Piper) writes:
- >
- >|My original question on this did not include an example which is probably why I
- >|was misunderstood. The scenario is this:
- >|
- >|class A {
- >| const int& a;
- >| A(const int& i) : a(i) {}
- >| A() : a(0) {}
- >|};
- >|
- >|class B : virtual public A {
- >| B(const int &i) : A(i) {}
- >|};
- >|
- >|class C : public B {
- >| C(const int& i) : B(i) {}
- >|};
- >|
- >|The reason I asked is that if you create an object of type C then B's
- >|initialisation of A is ignored and the default constructor is used instead ...
- >
- >That's correct.
- >
- >|So how do I initialise the reference ? Well cfront
- >|3.0.1 allows me to access the constructor of A directly from the constructor
- >|of C so I can write:
- >|
- >|class C : public B {
- >| C(const int& i) : B(i), A(i) {}
- >|};
- >|
- >|Which solves my original question.
- >
- >Right. This area of the language changed, and older compilers might
- >not work this way. Relatively recent compilers should support this
- >code, and so should all future compilers.
- >--
- >
- >Steve Clamage, TauMetric Corp, steve@taumet.com
-
- >
- >Hopefully the sections on virtual base classes for the final standard
- >will be heavily edited by someone with a nack for logical expression
- >in English. Those sections are really a mess in the ARM.
-
- Even better, the rule for virtual base initialisation
- could be improved so you dont have to init every VB in the complete
- object .. a real mess when you're mixing 20 VB together.
-
- Very much agreed. C++ could do with a general upgrade to support
- large scale use of virtual base classes. Current C++ facilities are
- very clumsy for handling problems much past the toy level.
-
- --
- ;----------------------------------------------------------------------
- JOHN (MAX) SKALLER, maxtal@extro.ucc.su.oz.au
- Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
- ;------ SCIENTIFIC AND ENGINEERING SOFTWARE ---ph: 2 799 8223 --------
-
- Doug
- --------------------------------------------------------------------
- Doug Morgan, doug@ads.com, (415) 960-7300
- Advanced Decision Systems (a division of Booz-Allen & Hamilton Inc.)
- 1500 Plymouth St., Mountain View, CA 94043-1230
- --------------------------------------------------------------------
-