with ada.integer_text_io; use ada.integer_text_io;
with ada.float_text_io; use ada.float_text_io;
with ada.text_io; use ada.text_io;
with Ada.Unchecked_Deallocation;
with System.Address_Image;
procedure accessrecords is
function aimg (a : System.Address) return String
renames System.Address_Image;
type rec_int is record x, y: Integer; end record;
type rec_flt is record x, y: Float; end record;
type ari is access rec_int;
type arf is access rec_flt;
procedure dispose is new Ada.Unchecked_Deallocation (rec_int, ari);
i1, i2 : ari;
f1 : arf;
begin
i1 := new rec_int'(11, 12);
i2 := i1;
put_line ("i1 address: " & aimg (i1.all'address)); -- i1 address: 08087008
put_line ("i2 address: " & aimg (i1.all'address)); -- i2 address: 08087008
put (i2.all.x, 6); -- 11 12
put (i2.all.y, 6);
new_line;
dispose (i1);
f1 := new rec_flt'(11.0, 12.0);
put_line ("f1 address: " & aimg (f1.all'address)); -- af1 address: 08087008
put (f1.all.x, 4, 1, 0); -- 11.0 12.0
put (f1.all.y, 4, 1, 0);
new_line;
put (i2.all.x, 12); -- 1093664768 1094713344
put (i2.all.y, 12);
new_line;
end accessrecords;