エイダでは、私は以下のspecファイルがあります。変数の初期化
GENERIC
TYPE Item IS PRIVATE; --type of array
size : integer; --size of array
PACKAGE gwar IS
function get_size return integer;
END gwar;
と身体ファイルを:
with Ada.Text_Io;
use Ada.Text_Io;
package body gwar is
--Get_Size allows the txt file to specify how much space to allocate.
function get_size return Integer is
Filename : String := "win.txt";
File : Ada.Text_IO.File_Type;
Line_Count : Integer := 0;
ReturnSize : Integer;
begin
Ada.Text_IO.Open(File => File,
Mode => Ada.Text_IO.In_File,
Name => Filename);
while Line_Count /= 1 loop
declare
Line : String := Ada.Text_IO.Get_Line(File);
begin
ReturnSize := Integer'Value(Line);
Line_Count := 1;
end;
end loop;
Ada.Text_IO.Close (File);
return ReturnSize;
end get_size;
begin
null;
end gear;
私は設定されてやりたい私size
get_size
によって返される値の整数。これどうやってするの?私はsize
変数の前に私の関数を配置しようとしましたが、ファイルの終わりが予想されました。私はsize : integer := gwar.get_size
を設定しようとしましたが、それはどちらも動作しません。これは可能ですか?
あなたのサイズvarは、ジェネリック仕様の一部です。ジェネリック仕様の外に移動し、ジェネリックをインスタンス化してから、get_size関数を呼び出す必要があります。 – NWS
'in out'の一般的な形式の' size'を作ることができます - [ARM 12.4](http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-12-4.html) –