home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #5 / Amiga Plus CD - 2000 - No. 5.iso / Tools / Dev / fpc / source / docs / refex / ex16.pp < prev    next >
Encoding:
Text File  |  2000-01-01  |  558 b   |  38 lines

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