通用子程序

通用子程序可用于创建具有相同结构的子程序,用于多种类型。例如,要交换两个对象:

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;