new class 2



new class 2
Smart pascal source code
type TMyClass = class constructor Build(i: Integer); virtual; default; end; type TSubClass = class(TMyClass) constructor Build(i: Integer); override; end; constructor TMyClass.Build(i: Integer); begin WriteLn('Root class '); WriteLn(i); end; constructor TSubClass.Build(i: Integer); begin WriteLn('Sub class '); WriteLn(i); end; var o1 := new TMyClass(10); var o2 := new TSubClass(20); WriteLn(o1.ClassName); WriteLn(o2.ClassName); {<<< RESULT - CONSOLE LOG >>> ----------------------------- Root class 10 Sub class 20 TMyClass TSubClass ----------------------------- {<<<<<<<<< THE END >>>>>>>>>}