Article View: borland.public.cppbuilder.nativeapi
Article #4780Re: inherited Create;
From: Remy Lebeau (TeamB)
Date: Thu, 01 Dec 2005 09:44
Date: Thu, 01 Dec 2005 09:44
37 lines
2604 bytes
2604 bytes
"Alistair" <NoSpamPlease@Somewhere.Com> wrote in message news:438eb24c$1@newsgroups.borland.com... > I have another method in my class Base called DoExecute(), > that calls the Execute method. e.g. > > // I WANT THIS FUNCTION IN THE BASE CLASS > TO CALL THE Execute() IN THE DERIVED CLASS That is exactly what actually happens when you call a virtual method that has been overriden. > Since I have overridden the Execute method in my Derived class, > shouldn't that call the Execute method in the Derived class? Usually, yes. The *only* time that it would not do so is when you call Execute() in the context of either the constructor or destructor of the Base class. In those two specific circumstances, the Derived class does not exist, so Derived::Execute() cannot be executed. You have not shown where exactly you are actually calling DoExecute() from. Please show a full code example that actually compiles. Otherwise, there is no way to know for sure why Derived::Execute() is not being called for you. My guess, based on this discussion so far, would be that you are calling DoExecute() in the Base class constructor, is that correct? > Or am I getting this all wrong? I either get the base method > called and not the derived or I get a pure function call error. Since Execute() is a pure abstract method in the Base class, the only way to get such a runtime error means that the Derived class does not exist at the time of the call. Which goes back to the theory that you are calling DoExecute() from either the constructor or destructor of the Base class. Gambit
Technical Details
Message-ID:
<438ec656$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news.moat.net!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<438e31c6$1@newsgroups.borland.com> <438e3b10$1@newsgroups.borland.com> <438eb24c$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,3e5cce9567b943d3 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <438e31c6$1@newsgroups.borland.com> <438e3b10$1@newsgroups.borland.com> <438eb24c$1@newsgroups.borland.com> Subject: Re: inherited Create; Date: Thu, 1 Dec 2005 01:44:54 -0800 Lines: 39 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <438ec656$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1133430358 68.69.17.41 (1 Dec 2005 01:45:58 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news.moat.net!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail