From 8905006379029103116
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,3cdb654b702f7476
X-Google-Attributes: gidf78e5,public
From: "Gerhard W. Gruber" <sparhawk@gmx.at>
Subject: Re: virtual functions
Date: 2000/08/17
Message-ID: <399B8FA6.540D5B7F@gmx.at>#1/1
X-Deja-AN: 659427920
Content-Transfer-Encoding: 7bit
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
References: <399A78E4.8345D7B@gmx.at> <m23dk5jiuq.fsf@brownie.frogger.foobar.snot>
X-Accept-Language: en
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Trace: mail2news.demon.co.uk 966536631 mail2news:25929 mail2news mail2news.demon.co.uk
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
MIME-Version: 1.0
Newsgroups: comp.std.c++

"llewelly."@@edevnull.dot.com wrote:

> Your compiler is correct in this case; if a virtual function is called
>   from inside a constructor, the method of that class - *not* the
>   overriding method - is called.

Is this only true for the constructor? From your statement it appears
so, but I'm not sure on this.

> It seems to me that a virtual initialization method such as what you
>   want implies a close coupling between the implementation of the base
>   class's constructor and the derived class. How could the author of
>   the overriding virtual initialization method know what to
>   initialize without understanding the implementation of the base
>   class's constructor? Such tight coupling is usually poor design, as
>   it makes derived classes likely to break when the implementation of
>   the base class is changed.

I don't really see why this should be poor design. When I call the base
class constcructor, I can assume that the class is properly initialized
(That's what the constructor is for, isnt't it?). So when the base class
constructor returns I can change part of the initialization in the
derived class that fits the derivation. Isn't that so?

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]




