🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #4777

Re: inherited Create;

#4777
From: Alistair
Date: Thu, 01 Dec 2005 08:21
42 lines
2240 bytes
Ah I see, I have been trying to get my virtual function to call.

I create a virtual method in class Base:

protected:
virtual void __fastcall Execute() = 0;

Which class Derived : public Base then overrides.

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
void __fastcall Base::DoExecute()
{
  Execute(); //Also tried Base::Execute();
}
void __fastcall Base::Execute()
{
  MessageBox(0, "BASE","TEST",MB_OK);
}

//Derived Class
void __fastcall Derived::Execute()
{
  MessageBox(0, "DERIVED","TEST",MB_OK); // THIS ISN'T CALLED
}

Since I have overridden the Execute method in my Derived class, 
shouldn't that call the Execute method in the Derived class?

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.  I have declared 
the Execute virtual function in the protected area of the Base class and 
  the overridden version in the protected area of my Derived class.

Can you point out my error?

Thanks for the excellent reply before.

Alistair
Technical Details
Message-ID: <438eb24c$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <438e31c6$1@newsgroups.borland.com> <438e3b10$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
Date: Thu, 01 Dec 2005 08:21:13 +0000
From: Alistair <NoSpamPlease@Somewhere.Com>
User-Agent: Thunderbird 1.4 (Windows/20050908)
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: inherited Create;
References: <438e31c6$1@newsgroups.borland.com> <438e3b10$1@newsgroups.borland.com>
In-Reply-To: <438e3b10$1@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 84.9.168.65
Message-ID: <438eb24c$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1133425228 84.9.168.65 (1 Dec 2005 00:20:28 -0700)
Lines: 42
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail