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

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -