ex16.pp 558 B

12345678910111213141516171819202122232425262728293031323334353637
  1. Program Example16;
  2. { Program to demonstrate the Dispose and New functions. }
  3. Type SS = String[20];
  4. AnObj = Object
  5. I : integer;
  6. Constructor Init;
  7. Destructor Done;
  8. end;
  9. Var
  10. P : ^SS;
  11. T : ^AnObj;
  12. Constructor Anobj.Init;
  13. begin
  14. Writeln ('Initializing an instance of AnObj !');
  15. end;
  16. Destructor AnObj.Done;
  17. begin
  18. Writeln ('Destroying an instance of AnObj !');
  19. end;
  20. begin
  21. New (P);
  22. P^:='Hello, World !';
  23. Dispose (P);
  24. { P is undefined from here on !}
  25. New(T,Init);
  26. T^.i:=0;
  27. Dispose (T,Done);
  28. end.