home *** CD-ROM | disk | FTP | other *** search
- -- Chapter 13 - Programming Exercise 2
- -- Chapter 13 - Program 1
- with Text_IO, Unchecked_Deallocation;
- use Text_IO;
-
- procedure Ch13_2a is
-
- package Int_IO is new Text_IO.Integer_IO(INTEGER);
- use Int_IO;
-
- type POINT_SOMEWHERE is access INTEGER;
- Index,Arrow,There : POINT_SOMEWHERE;
-
- procedure Free is new
- Unchecked_Deallocation(INTEGER, POINT_SOMEWHERE);
-
- begin
- Index := new INTEGER;
- Index.all := 13;
- Put("The value is");
- Put(Index.all);
- New_Line;
-
- Arrow := new INTEGER;
- Arrow.all := Index.all + 16;
- There := Arrow;
- Put("The values are now");
- Put(Index.all);
- Put(Arrow.all);
- Put(There.all);
- New_Line;
-
- There.all := 21;
- Put("The values are now");
- Put(Index.all);
- Put(Arrow.all);
- Put(There.all);
- New_Line;
-
- Free(Index);
- Free(Arrow);
-
- end Ch13_2a;
-
-
-
-
- -- Result of execution
-
- -- The value is 13
- -- The values are now 13 29 29
- -- The values are now 13 21 21
-
- -- Note that the Free procedure in line 41 could have been done
- -- with the access variable There since it is also accessing
- -- that data. Both could not be used however.
-
-