pascalabcnet/TestSamples/CompilationSamples/Template.pas
Бондарев Иван e6e67c193c initial commit
2015-05-14 21:35:07 +02:00

30 lines
661 B
ObjectPascal

type
Pair<T,Q> = template class
public
First: T;
Second: Q;
constructor(First: T; Second: Q);
begin
Self.First := First;
Self.Second := Second;
end;
class function operator+(Left,Right: Pair<T,Q>): Pair<T,Q>;
begin
Result := new Pair<T,Q>(Left.First + Right.First,
Left.Second + Right.Second);
end;
function ToString: string; override;
begin
Result := string.Format('[{0}; {1}]', First, Second);
end;
end;
var
a,b: Pair<integer, string>;
begin
a := new Pair<integer,string>(1, 'îäèí ');
b := new Pair<integer,string>(2, 'äâà');
Writeln(a + b);
readln;
end.