这个Ada程序有什么错误?

时间:2017-08-21 18:29:37

标签: compiler-errors ada

此Ada2012计划中的错误是什么?

with Ada.Iterator_Interfaces;

package My is

   type Cursor is private;

   function Has_Element (Position: Cursor) return Boolean;

   package Base_Iterators is new Ada.Iterator_Interfaces(Cursor, Has_Element);

   type Bindings_Iterator is new Base_Iterators.Forward_Iterator with private;

   overriding function First (Object: Bindings_Iterator) return Cursor;

   overriding function Next (Object: Bindings_Iterator; Position: Cursor) return Cursor;

private

   type Iterated_Object is access all Integer;

   type Cursor is new Iterated_Object;

   type Bindings_Iterator is new Base_Iterators.Forward_Iterator with null record;

end My;

尝试检查语法和语义:

$ gnatgcc -gnat2012 -c my.ads 
my.ads:23:09: type must be declared abstract or "First" overridden
my.ads:23:09: "First" has been inherited from subprogram at a-iteint.ads:26, instance at line 9

据我所知,First被我覆盖了。我没有得到编译器投诉的内容。

1 个答案:

答案 0 :(得分:2)

错误来自Cursor是一种私有派生的访问类型。将其更改为

type Cursor is access all Integer;

删除错误,将其更改为记录类型或数字类型。 将Iterated_ObjectCursor的完整定义移至公共视图也会删除错误。

我认为你偶然发现了编译器错误。