Complete Example
The following is the form unit code demonstrating the class above. It assumes a form with a button on it. Note that you add the member modifiers to the member declaration but not when you implement it.
unit MemberModifiersUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TCyborg = class(TObject)
public
procedure Speak(pMessage: String); virtual;
end;
TSeries888 = class(TCyborg)
public
procedure Speak(pMessage: String); override;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
Vick: TSeries888;
begin
Vick := TSeries888.Create;
Vick.Speak('Hello, I am Vick.');
end;
{ TCyborg }
procedure TCyborg.Speak(pMessage: String);
begin
//Default cyborg voice.
ShowMessage(pMessage);
end;
{ TSeries888 }
procedure TSeries888.Speak(pMessage: String);
begin
//Series 888 voice.
ShowMessage(pMessage);
end;
end.