free | destroy



free | destroy
Smart pascal source code
// #################################### // TFirstClass // #################################### Type TFirstClass = Class(TObject) private Public Constructor Create; virtual; Destructor Destroy; override; End; Constructor TFirstClass.Create; Begin WriteLn('Create ' + Classname); inherited Create; end; Destructor TFirstClass.Destroy; begin WriteLn('Destroy ' + Classname); inherited Destroy; end; // #################################### // TSecondClass // #################################### type TSecondClass = Class(TFirstClass) private FTemp: TFirstClass; public Constructor Create; Override; Destructor Destroy; Override; End; Constructor TSecondClass.Create; Begin WriteLn('2nd Create ' + Classname); inherited Create; FTemp := TFirstClass.Create; end; Destructor TSecondClass.Destroy; begin WriteLn('2nd Destroy ' + Classname); FTemp.free; inherited Destroy; end; // #################################### // Test // #################################### var First: TFirstClass; First := TFirstClass.Create; var Second: TSecondClass; Second := TSecondClass.Create; First.free; Second.free; {<<< RESULT - CONSOLE LOG >>> ----------------------------- Errors >>>> Hint: "Classname" does not match case of declaration ("ClassName") [line: 16, column: 21] Hint: "Classname" does not match case of declaration ("ClassName") [line: 22, column: 22] Hint: "Classname" does not match case of declaration ("ClassName") [line: 42, column: 25] Hint: "Classname" does not match case of declaration ("ClassName") [line: 49, column: 26] Hint: "free" does not match case of declaration ("Free") [line: 50, column: 9] Hint: "create" does not match case of declaration ("Create") [line: 63, column: 22] Hint: "free" does not match case of declaration ("Free") [line: 65, column: 7] Hint: "free" does not match case of declaration ("Free") [line: 66, column: 8] Result >>>> Create TFirstClass 2nd Create TSecondClass Create TSecondClass Create TFirstClass Destroy TFirstClass 2nd Destroy TSecondClass Destroy TFirstClass Destroy TSecondClass ----------------------------- {<<<<<<<<< THE END >>>>>>>>>}