我是新來的Ada,我試圖創建一個記錄數組,然後把一些記錄放到數組中,但是我得到錯誤nested array aggregate expected
。這是我的代碼:Ada編程數組記錄
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_Io;
with Ada.unchecked_conversion;
procedure main is
type Byte is range 0..255;
for Byte'Size use 8;
type Pixel is record
R:Byte;
G:Byte;
B:Byte;
end record;
for Pixel'Size use 24;
r1:Pixel := (1,2,5);
r2:Pixel := (1,2,3);
r3:Pixel := (1,2,3);
type Image is array(Positive range <>, Positive range <>) of Pixel;
Pragma Pack(Image);
Left:Image(1..3, 1..1) := (r1, r2, r3);
begin
null;
end main;
你聲明'圖像「作爲像素的二維陣列,但是然後爲其分配一維像素陣列。這三個像素代表什麼?頂部行左邊的三個像素還是最左邊一列的頂部? – 2014-10-02 14:58:57