[英]GNAT Studio ADA getting error "expected type "Standard.Integer"
在关于 Arrays 的 Ada 简介课程部分中,它表明我可以使用用户定义的类型“索引”来索引数组,但是当我尝试使用用户定义的类型来索引数组时,它会显示预期类型“标准整数”。 我问这个的原因是因为它明确指出您可以使用任何离散类型来索引数组。
procedure Cipher is
type Byte is mod 2**8;
type BufferArray is array ( 0 .. 15 ) of Byte;
type Index is range 1 .. 16;
Buffer: BufferArray := (0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
buber: Byte := 255;
begin
-- Insert code here.
for I in Index loop
Put( Byte'Image(Buffer(I)) ); --error shows up here
end loop;
null;
end Cipher;
这个特定版本的 GNAT 是否有问题?
您将数组定义为使用您自己定义的类型进行索引:
type BufferArray is array (Index) of Byte;
作为奖励,此定义会自动删除代码中的一个错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.