declaration - Ada: Access types and invalid completion with records -


i'm learning ada , using book rendez-vous ada naiditch (1995). on page 385, example given package specification file incomplete type declaration:

package restaurant_linked_list     subtype name_type string (1..20);    type restaurant_record private;     procedure add_to_list (new_entry: in restaurant_record);    procedure (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 (chinese, japanese, french, korean, mexican, italian, jewish, american, german);       subtype price_type float range 0.0 .. 150.0;       type restaurant_record; -- incomplete type declaration       type restaurant_pointer access restaurant_record;       type restaurant_record -- complete type declaration         record            name: name_type;            food: ethnicity;            average_price: price_type;            next: restaurant_pointer;         end record;  end restaurant_linked_list;  

however on compilation of primary unit -gnat95 switch, error message:

15:11 invalid completion of private type "restaurant_record" defined @ line 4

where line 15 line: type restaurant_record; -- incomplete type declaration.

naiditch proposed above workaround have pointer (restaurant_pointer) component of type of object can point written on page 384 in book.

so how fix above code?

thank you.

the declaration @ line 4 enough allow declare restaurant_pointer. delete line 15.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -