Article View: alt.comp.lang.learn.c-c++
Article #114Re: Base - derived problem.
From: Chris Newton
Date: Mon, 26 Jul 1999 00:00
Date: Mon, 26 Jul 1999 00:00
23 lines
1784 bytes
1784 bytes
Tony Colston wrote... > I think that your problem has something to do with when > an object get constructed. Or even how it gets constructed :-). You are quite right, though, the explanation is that when the base class's constructor is called, the object is still only an instance of the base class, it is not yet an instance of the derived class. Hence, the base class's version of the virtual function is called. The C++ FAQ, at http://www.cs.bham.ac.uk/~jdm/CPP/index.html has a little more explanation. As for how to get around the problem, don't quote me, but I believe Meyers discusses this issue in either Effective C++ or More Effective C++. I don't have my copies to hand, but I'll try to look them up later. Regards, Chris -- Please reply to this newsgroup. To mail me privately, lose the "spamfree". alt.comp.lang.learn.c-c++ FAQ: http://www.raos.demon.co.uk/acllc-c++/faq.html
Technical Details
Message-ID:
<7niec0$7dv$1@pegasus.csx.cam.ac.uk>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<wQUm3.8699$D4.125836@news.tpnet.pl> <7ni1cd$c8s$1@news.socomm.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10d4ba,4a24208a4bcf639b X-Google-Attributes: gid10d4ba,public X-Google-Thread: 114592,4a24208a4bcf639b X-Google-Attributes: gid114592,public X-Google-Thread: 108b44,4a24208a4bcf639b X-Google-Attributes: gid108b44,public X-Google-Thread: fe105,4a24208a4bcf639b X-Google-Attributes: gidfe105,public From: "Chris Newton" <can21@spamfree.cam.ac.uk> Subject: Re: Base - derived problem. Date: 1999/07/26 Message-ID: <7niec0$7dv$1@pegasus.csx.cam.ac.uk> X-Deja-AN: 505496858 References: <wQUm3.8699$D4.125836@news.tpnet.pl> <7ni1cd$c8s$1@news.socomm.net> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Organization: University of Cambridge, England X-MSMail-Priority: Normal Newsgroups: alt.comp.lang.learn.c-c++,att.lang.c++,comp.sys.lang.c++,pl.comp.programming