According to this post, I'v try to do a record with a private part. What I've done :
MyFile.ads :
package MyPackage is
type T_MyType is tagged private;
private
type T_MyType_Private_Part;
type T_MyType_Private_Part_Access is access T_MyType_Pirvate_Part;
type T_MyType is tagged record
Toto : Boolean;
end record
end MyPackage;
MyFile.adb :
package body MyPackage is
type T_MyType_Private_Part is record
Private_Toto : Boolean;
end record
end MyPackage;
But when an other package do MyVar.Toto where MyVar is T_MyType I have the error :
no selector "Toto" for type "T_MyType" defined at MyFile.ads
How can I fix this ?
It is very simple to produce a record with a private part using Ada.
The following example declares a base tagged type with a public member. It then creates a child package which extends the tagged type with private members. The type declared in the child package has both a public and private data members.
The package named base_type declares a tagged record with a public member. The
The body of base_type.person is
A should be expected, the private data members may only be accessed through procedures and functions.
A main procedure creating a program example is
The output of this program is: