package Bird_Package is
type Bird_Type is tagged private;
procedure Init(A_Bird : out Bird_Type; Name : in String);
function Name(A_Bird : in Bird_Type) return String;
function Call(A_Bird : in Bird_Type) return String;
function Type_Name(A_Bird : in Bird_Type) return String;
procedure Put(A_Bird : in Bird_Type);
private
type Bird_Type is tagged record
My_Name : String (1..6);
end record;
end Bird_Package;
Package Body Bird_Package is
procedure Init(A_Bird: out Bird_Type; Name : in String) is
begin
A_Bird.My_Name := Name;
end Init;
function Name(A_Bird : in Bird_Type) return String is
begin
return A_Bird.A_Name;
end Name;
function Call(A_Bird : in Bird_Type) return String is
begin
return "Squawwwwwwk!";
end Call;
function Type_Name(A_Bird : in Bird_Type) return String is
begin
return "Bird";
end Type_Name;
procedure Put(A_Bird : in Bird_Type'Class) is
begin
Put( Name(A_Bird) );
Put( ' ' );
Put( Type_Name(A_Bird) );
Put( " says " );
Put( Call(A_Bird) );
end Put;
end Bird_Package;
I have a problem with the package body I do not understand what Bird_Type'Class is so therefore I do not know how to apply it in my client program. It keeps telling me that the expected type is Bird_Type'Class, but the type it is finding is Standard String. Help is appreciated, thank you