我很确定这很简单:)
我有一个抽象的标记类型NamedStructure,在规范的私有部分有三个字段:
数组名称(a string)
(a
)(正数)
然后我创建了一个子类Chord,它基本上是:
type Chord is new NamedStructure with null record;
使用Spark时,我需要初始化chord对象,但我遇到了一个问题。
Chord_Object : Chord := (NamedStructure'(Name => "",
Structure => (Others => False),
Number_Of_Notes => 0) with null record);
不能编译,错误消息是
scalada-chords.adb:44:53: expected private type "NamedStructure" defined at scalada-namedstructures.ads:52
scalada-chords.adb:44:53: found a composite type
我找不到使用extension aggregate的正确结构,也不明白为什么。有什么想法吗?
发布于 2019-03-15 04:05:44
该错误表明NamedStructure
是私有类型,因此无法使用聚合进行初始化。你可以试试
type Chord is new NamedStructure with null record;
Chord_Object : Chord := (NamedStructure with null record);
尽管NamedStructure
的实例字段现在将保持未初始化状态。
https://stackoverflow.com/questions/55170289
复制相似问题