I've got a simple package in Ada with procedures and functions. I'd like to have all the functions and procedures in a protected type.
e.g. for a simple .adb file
package body Pack is
procedure procedure1 (B : in out Integer) is
begin
B := new Integer;
end procedure1;
procedure procedure2 (B: in out Integer) is
begin
B.Cont(B.First-1) := 1;
end procedure2;
function procedure3 (B : Integer) return Boolean is
begin
return B.First = B.Last;
end procedure3;
end pack;
and or a simple .ads
package body Pack is
procedure procedure1 (B : in out Integer);
procedure procedure2 (B: in out Integer);
function procedure3 (B : Integer) return Boolean;
end pack;
How would I go about it?
procedure1, B is declared asIntegerbut you then assign an access value to it (new Integer). And in the other two subprograms, B appears to be a record type. And the reserved wordbodycan’t appear in a package spec. - Simon Wright