Article View: borland.public.cppbuilder.nativeapi
Article #4772inherited Create;
From: Alistair
Date: Wed, 30 Nov 2005 23:12
Date: Wed, 30 Nov 2005 23:12
62 lines
2665 bytes
2665 bytes
I am looking at the classes.pas in the source for Borland and I have
noticed that :
constructor TThread.Create(CreateSuspended: Boolean);
var
Flags: DWORD;
begin
inherited Create; <-- THIS CALLS THE INHERITED FUNCTION ...
AddThread;
FSuspended := CreateSuspended;
Flags := 0;
if CreateSuspended then Flags := CREATE_SUSPENDED;
FHandle := BeginThread(nil, 0, @ThreadProc, Pointer(Self), Flags,
FThreadID);
end;
So is this possible in C++? Can I declare a class A with a Do() method
and then have that Do() method in class A (base class) call the
inherited version in class B ( where class B : public A { ... }; ) ??
Basically, I am looking at creating my own class that does exactly what
TThread does. E.g. :
class MyThread(bool CreateSuspended) : public TThread(CreateSuspended)
{
protected:
void __fastcall Execute()
{
// Code To Execute In The Thread
}
};
Somehow the base TThread class calls the Execute in the class that
inherits TThread, I am assuming it does this by the 'inherited Create;'.
Basically the inherited function Create(CreateSuspended: Boolean) within
the MyThread class is executed and thus the MyThread Execute() is also
executed according to the base class (ThreadProc is the function passed
into the CreateThread equivalent BeginThread :
function ThreadProc(Thread: TThread): Integer;
var
FreeThread: Boolean;
begin
try
Thread.Execute; <--- HERE !!!!
finally
FreeThread := Thread.FFreeOnTerminate;
Result := Thread.FReturnValue;
Thread.FFinished := True;
Thread.DoTerminate;
if FreeThread then Thread.Free;
EndThread(Result);
end;
end;
Any help on how to do this would be appreciated.
Alistair
Technical Details
Message-ID:
<438e31c6$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.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-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,3e5cce9567b943d3,start X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Wed, 30 Nov 2005 23:12:50 +0000 From: Alistair <NoSpamPlease@Somewhere.Com> User-Agent: Thunderbird 1.4 (Windows/20050908) MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: inherited Create; Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 84.9.168.65 Message-ID: <438e31c6$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1133392326 84.9.168.65 (30 Nov 2005 15:12:06 -0700) Lines: 62 Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.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