-- Chapter 13 - Programming Exercise 2 -- Chapter 13 - Program 2 with Ada.Text_IO, Unchecked_Deallocation; use Ada.Text_IO; procedure Ch13_2b is package Int_IO is new Ada.Text_IO.Integer_IO(INTEGER); use Int_IO; package Flt_IO is new Ada.Text_IO.Float_IO(FLOAT); use Flt_IO; type POINT_TO_INT is access INTEGER; Index,Arrow : POINT_TO_INT; type POINT_TO_FLOAT is access FLOAT; X,Y,Z : POINT_TO_FLOAT; procedure Free is new Unchecked_Deallocation(INTEGER, POINT_TO_INT); procedure Free is new Unchecked_Deallocation(FLOAT,POINT_TO_FLOAT); begin Index := new INTEGER'(173); Arrow := new INTEGER'(57); Put("The values are"); Put(Index.all, 6); Put(Arrow.all, 6); New_Line; Index.all := 13; Arrow.all := Index.all; Index := Arrow; X := new FLOAT'(3.14159); Y := X; Z := X; Put("The float values are"); Put(X.all, 6, 6, 0); Put(Y.all, 6, 6, 0); Put(Z.all, 6, 6, 0); New_Line; X.all := 2.0 * Y.all; Put("The float values are"); Put(X.all, 6, 6, 0); Put(Y.all, 6, 6, 0); Put(Z.all, 6, 6, 0); New_Line; Free(Index); Free(X); end Ch13_2b; -- Result of execution -- The values are 173 57 -- The float values are 3.141590 3.141590 3.141590 -- The float values are 6.283180 6.283180 6.283180 -- Note that the deallocations could be done with any of the -- variable names since all variables of the same type are point- -- ing to the same places. -- Note also that the two procedures could be named something else -- rather than overloading the name Free. It would be better -- practice to use different names for the variables.