ada Generic Subprograms


Example

Generic subprograms are usefull to create a subprograms that have the same structure for several types. For example, to swap two objects:

generic
    type A_Type is private;
procedure Swap (Left, Right : in out A_Type) is
    Temp : A_Type := Left;
begin
    Left := Right;
    Right := Temp;
end Swap;