// Inherited is a special command for calling the parent class method; example: Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls; type tform1 = Class (tform) button1: tbutton; Procedure button1click (Sender: tobject); end; {create a parent class, class includes a function fun and a virtual method proc} tbass = Class procedure proc; virtual; function fun (X, Y: integer): string; end; {four subclasses are created, respectively covering the Virtual Methods of the parent class} tchild1 = Class (tbass) Procedure proc; override; end; tchild2 = Class (tbass) Procedure proc; override; end; tchild3 = Class (tbass) Procedure proc; override; end; tchild4 = Class (tbass) Procedure proc; override; end; var form1: tform1; implementation {$ R *. DFM} {tbass} function tbass. fun (X, Y: integer): string; begin result: = inttostr (x + y); {the parent class function returns the sum of two values.} end; Procedure tbass. proc; begin showmessage ('tbass '); {the virtual method of the parent class will pop up information: tbass} end; {tchild1} procedure tchild1.proc; begin inherited proc; {call the proc method} end of the parent class; {tchild2} procedure tchild2.proc; begin inherited; {call the method with the same name as the parent class can omit the method name} showmessage ('tchild2 '); {then pop up your own information box} end; {tchild3} procedure tchild3.proc; begin showmessage ('tchild3 '); {first pop up your own information box} inherited; {call the method with the same name as the parent class} end; {tchild4} procedure tchild4.proc; begin showmessage (inherited fun (); {call the summation function of the parent class} end; {test} procedure tform1.button1click (Sender: tobject); var C1: tchild1; C2: tchild2; C3: tchild3; C4: tchild4; begin C1: = tchild1.create; C2: = tchild2.create; c3: = tchild3.create; C4: = tchild4.create; c1.proc; {explicit: tbass} c2.proc; {First: tbass; then: tchild2} c3.proc; {First: tchild3; again: tbass} c4.proc; {display: 33; 11 + 22 = 33?} c1.free; c2.free; c3.free; c4.free; end.