Reputation: 1641
Well I'm quite sure this is easy :)
I have an abstract tagged type NamedStructure having three fields in the private part of the spec:
I then created a subclass Chord which is basically:
type Chord is new NamedStructure with null record;
Playing around with Spark, I need to initialize my chord objects but I face a problem.
Chord_Object : Chord := (NamedStructure'(Name => "",
Structure => (Others => False),
Number_Of_Notes => 0) with null record);
doesn't compile and the error message is
scalada-chords.adb:44:53: expected private type "NamedStructure" defined at scalada-namedstructures.ads:52
scalada-chords.adb:44:53: found a composite type
I don't find the correct construction using the extension aggregate and I don't see why. Any idea ?
Upvotes: 1
Views: 531
Reputation: 5941
The error suggests that NamedStructure
is a private type and therefore cannot be initialized using an aggregate. You might try
type Chord is new NamedStructure with null record;
Chord_Object : Chord := (NamedStructure with null record);
although the instance fields of NamedStructure
will now remain uninitialized.
Upvotes: 2