use*_*206 0 declaration record ada
我正在学习阿达并正在使用这本书Rendez-vous with Ada by Naiditch (1995).在页面上385,给出了包含不完整类型声明的包规范文件的示例:
package Restaurant_Linked_List is
subtype Name_Type is String (1..20);
type Restaurant_Record is private;
procedure Add_To_List (New_Entry: in Restaurant_Record);
procedure Get (New_Restaurant: out Restaurant_Record);
procedure Delete_From_List (Target: in Name_Type);
procedure Search_List (Target: in Name_Type);
procedure Output_List;
private
type Ethnicity is (Chinese, Japanese, French, Korean, Mexican, Italian, Jewish, American, German);
subtype Price_Type is Float range 0.0 .. 150.0;
type Restaurant_Record; -- incomplete type declaration
type Restaurant_Pointer is access Restaurant_Record;
type Restaurant_Record is -- complete type declaration
record
Name: Name_Type;
Food: Ethnicity;
Average_Price: Price_Type;
Next: Restaurant_Pointer;
end record;
end Restaurant_Linked_List;
Run Code Online (Sandbox Code Playgroud)
但是,即使使用-gnat95交换机编译此主要单元,我收到错误消息:
15:11第4行定义的私人类型"Restaurant_Record"无效完成
第15行是该行:键入Restaurant_Record; - 不完整的类型声明.
Naiditch提出了上述解决方法,使指针(Restaurant_Pointer)成为非常类型对象的一个组件,它可以指向384书中的页面.
那么如何修复上面的代码呢?
谢谢.