我想在我的实例化Ada.Containers.Doubly_Linked_Lists中添加一个过程,该过程将打印出列表。我还想隐藏一些功能和程序。如果有更好的方法,我很乐意阅读它,但是现在,我试图将实例化包装在另一个包中,这意味着创建一个新的List和Cursor。泛型定义它们如下:
type List is tagged private;
pragma Preelaborable_Initialization(List);
type Cursor is private;
pragma Preelaborable_Initialization(Cursor);
我已经尝试了
package Collection is new Ada.Containers.Doubly_Linked_Lists (New_Type);
type Cursor is new Collection.Cursor;
type List is new tagged Collection.List with private;
这似乎适用于Cursor,但List导致subtype indication expected
错误。
如何对像List这样的标记私有子类型进行子类型化?
答案 0 :(得分:2)
问题是你们都使用new
和tagged
:
with Ada.Containers.Doubly_Linked_Lists;
package Example is
type New_Type is new Integer;
package Collection is new Ada.Containers.Doubly_Linked_Lists (New_Type);
type Cursor is new Collection.Cursor;
type List is new Collection.List with private;
private
type List is new Collection.List with null record;
end Example;