Previous: Using New Procedure (OOP) To the Table of Content Next: Inherited reserved word

- 2.2.13.11 -
TMT Pascal Language Description
Pascal Language Structure
OOP Extensions

Desctructors

Destructors are used to clean up after an object is no longer needed. Unlike constructors, destructors can be virtual. Destruction of an object is often combined with deallocation of its memory with the Dispose procedure:
var
  C: ^Circle;
begin
  New(C);
  C.Init(P,R);
  ...
  C.Kill;
  Dispose(C);
end;
If a constructor fails to perform initialization (often because of its inability to allocate memory for the structures affiliated with the object, it can execute a special system function Fail. Fail signals TMT Pascal to reverse all allocation of the object that might have occurred and return nil as the value of the object's pointer. Fail can be called only within constructors.

See also:
Constructors


Previous: Using New Procedure (OOP) To the Table of Content Next: Inherited reserved word
Using New Procedure (OOP) Table of Content Inherited reserved word

- 2.2.13.11 -