Article View: alt.comp.lang.learn.c-c++
Article #112Base - derived problem.
From: Dobieslaw Wroblewski
Date: Mon, 26 Jul 1999 00:00
Date: Mon, 26 Jul 1999 00:00
46 lines
1889 bytes
1889 bytes
I've got something like that in my program:
------------------------------------------------------------
class Base {
protected:
virtual void SetupIt(void) {
message("base setup");
}
public:
Base (void) {
SetupIt();
}
}
class Derived : public Base {
protected:
virtual void SetupIt(void) {
message("derived setup");
}
public:
Derived (void) : Base () {
// additional instructions
}
}
Base *x;
x = new Derived();
-------------------------------------------------------------
And I get the "base setup" message while I want to
get the "derived setup".
I hope it is possible to do this (using the combination
of 'virtual' modifiers) without explicitly copying and pasting
the constructor's contents (which, in fact, is much longer
in my program;-).
Could anyone help me?
--
Yours D. Wroblewski
( wrobldob@kki.net.pl , wrobldob@wars.ipipan.waw.pl )
Technical Details
Message-ID:
<wQUm3.8699$D4.125836@news.tpnet.pl>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fe105,4a24208a4bcf639b,start X-Google-Attributes: gidfe105,public X-Google-Thread: 114592,4a24208a4bcf639b,start X-Google-Attributes: gid114592,public X-Google-Thread: 108b44,4a24208a4bcf639b,start X-Google-Attributes: gid108b44,public X-Google-Thread: 10d4ba,4a24208a4bcf639b,start X-Google-Attributes: gid10d4ba,public From: "Dobieslaw Wroblewski" <wrobldob@kki.net.pl> Subject: Base - derived problem. Date: 1999/07/26 Message-ID: <wQUm3.8699$D4.125836@news.tpnet.pl> X-Deja-AN: 505306489 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 X-Complaints-To: abuse@tpsa.pl X-Trace: news.tpnet.pl 932977052 212.160.54.238 (Mon, 26 Jul 1999 10:17:32 MET DST) Organization: TPNET - http://www.tpnet.pl NNTP-Posting-Date: Mon, 26 Jul 1999 10:17:32 MET DST Newsgroups: alt.comp.lang.learn.c-c++,att.lang.c++,comp.sys.lang.c++,pl.comp.programming