一种方法是将对象声明为由枚举类型索引的数组,该枚举类型的值是标识符。例如,如果标识符是符号A到Z,则可以将数组定义为:
subtype Index is Character range 'A'..'Z'; type Collection is array(Index) of Integer; Idx : Index; Value : Integer; The_Collection : Collection; while not End_Of_File(Input_File) loop Get(Idx); Get(Value); Skip_Line; The_Collection(Idx) := Value; end loop;
当然,您需要“使用”相应的I / O包。