简体   繁体   English

Ada嵌套通用包装

[英]Ada Nested Generic Package

I tried searching a lot for what I thought was Nested Generic Packages, which I don't know how to implement in Ada. 我试图搜索很多东西,以为嵌套通用包是什么,我不知道如何在Ada中实现。 I found no helpful references or sources online of what I am trying to accomplish so please tell me if it's possible or other ways to accomplish it. 我在网上找不到关于我要完成的工作的有用参考文献或资源,因此请告诉我是否有可能或要实现的其他方法。

package AdjList is new List(Integer);
package Graph is new List(AdjList);

I am getting compilation errors for these 2 lines regarding the type I am passing to the List generic package. 我收到有关传递给List通用包的类型的这两行的编译错误。

I am trying to have 2 nested lists which will form a type of graph and I am forced to use this implementation approach. 我试图有2个嵌套列表,这些列表将形成一种图形,因此我不得不使用这种实现方法。 Any ideas/thoughts? 有什么想法/想法吗?

The error comes from the fact that you are passing AdjList , which is a package to the parameter. 该错误来自以下事实:您传递了AdjList ,它是参数的包。 You need to pass a type that is the main data of that package. 您需要传递的类型是该程序包的主要数据。

package AdjList is new List(Integer);
package Graph is new List(AdjList.Data);   

根据编译器/设置开发环境的方式,您可能需要确保每个程序包实例都在单独的文件中(如果使用Gnat,则为.ads文件)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM