with Ada.Text_IO,Ada.Integer_Text_IO,Ada.Unchecked_Deallocation;
use Ada.Text_IO,Ada.Integer_Text_IO;
procedure Access3 is
type MY_RECORD is
record
Age:Integer;
Initial:Character;
Sex:Character;
end record;
type ACCESS_MY_DATA is access MY_RECORD;
procedure Free is new
Ada.Unchecked_Deallocation(MY_RECORD,ACCESS_MY_DATA);
Myself:ACCESS_MY_DATA;
Friend:ACCESS_MY_DATA:=new MY_RECORD'(30,'R','F');
Result:Boolean;
begin
Myself:=new MY_RECORD;
Myself.Age:=34;
Myself.Initial:='D';
Myself.Sex:='M';
Friend:=new MY_RECORD'(31,'R','F');
Put("My age is");
Put(Myself.Age,3);
Put(" and my initial is");
Put(Myself.Initial);
New_Line;
Friend.all:=Myself.all; -- the value stored at the place where object points
Result:=Friend.all=Myself.all; --true because of line 43
Result:=Friend=Myself;-- false because they point to different things
Free(Myself);
Free(Friend);
end Access3;
061.对记录型变量的访问
最新推荐文章于 2022-10-16 09:54:08 发布