好吧,我很确定这很容易:)
我有一个抽象标记类型 NamedStructure ,在规范的私有部分具有三个字段:
然后我创建了一个子类 Chord ,该子类基本上是:
type Chord is new NamedStructure with null record;
在玩Spark时,我需要初始化我的
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
我找不到使用扩展聚合的正确构造,也看不到为什么。有什么想法吗?
答案 0 :(得分:2)
该错误表明NamedStructure
是私有类型,因此无法使用聚合进行初始化。您可以尝试
type Chord is new NamedStructure with null record;
Chord_Object : Chord := (NamedStructure with null record);
尽管NamedStructure
的实例字段现在仍未初始化。