Function Pointer class method



Function Pointer class method
Smart pascal source code
type TProc = procedure; type TMyClass = class class procedure SayHello; virtual; begin WriteLn('Hello ' + ClassName); end; class procedure Hello; begin SayHello; end; end; type TMyChild = class(TMyClass) class procedure SayHello; override; begin WriteLn('Bye bye ' + ClassName); end; end; var p: TProc; p := TMyClass.Hello; p(); p := TMyChild.Hello; p(); var o1 := TMyClass.Create; p := o1.Hello; p(); var o2 := TMyChild.Create; p := o2.Hello; p(); {<<< RESULT - CONSOLE LOG >>> ----------------------------- Hello TMyClass Bye bye TMyChild Hello TMyClass Bye bye TMyChild ----------------------------- {<<<<<<<<< THE END >>>>>>>>>}