私有部分,数组和指针的约束错误

时间:2017-11-16 10:39:03

标签: arrays pointers constraints ada

我正在尝试使用此功能执行典型的Get过程:

部首:

class

私人部分:

procedure Get (M:Map; Key: in Key_Type; Value: out Value_Type; Success: out Boolean) is

我的Get程序的第一个条件有以下几个方面:

type Cell is record
    Key: Key_Type;
    Value: Value_Type;
    Full:Boolean:= False;
end record

type Cell_Array is array (1..50) of Cell;
type Cell_Array_A is access Cell_Array;

type Map is record   
    P_Array: Cell_Array_A;
    Length:Natural=0;
    Indice:Natural;
end record

但是当我尝试执行它时,它总是给我以下错误: Lower_Layer.Inet(Receiver_Task):引发意外异常CONSTRAINT_ERROR

我该如何解决? PS:Get程序和私有部分的标题是强制性的......

谢谢!

1 个答案:

答案 0 :(得分:3)

如果您消除了对访问类型的不必要使用,您的问题就会消失:

type Map is record
   List : Cell_Array;
   ...
end record;

在精心设计的Ada中很少需要访问类型,我很想说“从不”。