Although you can easily do this with classes, it is not so simple with other types such as integers, strings, and enumerations. Although they work with generics to some extent, they are small. On the other hand, in this case you do not need.
, , ( , ). , , , .
unit UnitTest1;
interface
type
THashTable = class
procedure AddString( const pName : string; pValue : string ); virtual; abstract; // dummy for illustration only
procedure AddInt( const pName : string; const pInt : integer ); virtual; abstract; // dummy for illustration only
end;
TMyClass = class
private
FHashTable : THashTable;
public
procedure TestString;
procedure TestInt;
procedure SetParam( const pName : string; const pValue : string ); overload;
procedure SetParam( const pName : string; const pValue : integer ); overload;
end;
implementation
{ TMyClass }
procedure TMyClass.SetParam(const pName, pValue: string);
begin
FHashTable.AddString( pName, pValue );
end;
procedure TMyClass.SetParam(const pName: string; const pValue: integer);
begin
FHashTable.AddInt( pName, pValue );
end;
procedure TMyClass.TestInt;
begin
SetParam( 'Int', 4 );
end;
procedure TMyClass.TestString;
begin
SetParam( 'Int', 'Fred' );
end;
end.
THashTable , FHashTable. . , , , .