Create a new VCL Forms Application project, Code Two
Class :
One is a tform class; the other is a tform1 class; tform1 inherits from tform.
Tform is the parent class of tform1, and tform1 is the Child class of tform.
unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls; Type tform1 = Class (tform) button1: tbutton; button2: tbutton; Procedure button1click (Sender: tobject); Procedure button2click (Sender: tobject); end; // two custom classes are defined below, tchild inherits from tbass = Class procedure msg1; end; tchild = Class (tbass) Procedure msg2; end; var form1: tform1; implementation {$ R *. DFM} {tbass} procedure tbass. msg1; begin showmessage ('is bass '); end; {tchild} procedure tchild. msg2; begin showmessage ('is child '); end; // Test 1: the parent class has only one method msg1procedure tform1.button1click (Sender: tobject); var B: tbass; begin B: = tbass. create; B. msg1; {is Bass} B. free; end; // Test 2: The subclass has two methods: msg2 and msg1procedure tform1.button2click (Sender: tobject); var C: tchild; begin C: = tchild. create; C. msg1; {is Bass} C. msg2; {is child} C. free; end.