home *** CD-ROM | disk | FTP | other *** search
/ Chip 1995 March / CHIP3.mdf / programm / prog2 / access4.ada < prev    next >
Encoding:
Text File  |  1991-07-01  |  995 b   |  49 lines

  1.                                        -- Chapter 13 - Program 4
  2. with Text_IO, Unchecked_Deallocation;
  3. use Text_IO;
  4.  
  5. procedure Access4 is
  6.  
  7.    package Int_IO is new Text_IO.Integer_IO(INTEGER);
  8.    use Int_IO;
  9.  
  10.    type MY_ARRAY is array(3..8) of INTEGER;
  11.    type POINT_TO_ARRAY is access MY_ARRAY;
  12.  
  13.    procedure Free is new
  14.                 Unchecked_Deallocation(MY_ARRAY,POINT_TO_ARRAY);
  15.  
  16.    List_Of_Stuff : MY_ARRAY := (34, 12, -14, 1, 27, -11);
  17.    There         : POINT_TO_ARRAY;
  18.    Here          : POINT_TO_ARRAY;
  19.  
  20. begin
  21.  
  22.    There := new MY_ARRAY;
  23.    There.all := List_Of_Stuff;
  24.    Here := There;
  25.  
  26.    for Index in MY_ARRAY'RANGE loop
  27.       Put(List_Of_Stuff(Index));
  28.       Put(There.all(Index));
  29.       Put(Here.all(Index));
  30.       New_Line;
  31.    end loop;
  32.  
  33.    Free(There);
  34.  
  35. end Access4;
  36.  
  37.  
  38.  
  39.  
  40. -- Result of execution
  41.  
  42. --     34    34    34
  43. --     12    12    12
  44. --    -14   -14   -14
  45. --      1     1     1
  46. --     27    27    27
  47. --    -11   -11   -11
  48.  
  49.