The following code demonstrated the conversion of a generic Delphi type to C++.
type
TPair<TKey,TValue> = class // declares TPair type with two type parameters
private
FKey: TKey;
FValue: TValue;
public
function GetKey: TKey;
procedure SetKey(key: TKey);
function GetValue: TValue;
procedure SetValue(Value: TValue);
property key: TKey Read GetKey Write SetKey;
property Value: TValue Read GetValue Write SetValue;
end;
type TSIPair = TPair<String,Integer>; // declares instantiated type TSSPair = TPair<String,String>; // declares with other data types TISPair = TPair<Integer,String>; TIIPair = TPair<Integer,Integer>; TSXPair = TPair<String,TXMLNode>;
implementation
function TPair<TKey,TValue>.GetValue: TValue; begin Result := FValue; end;
->
// declares TPair type with two type parameters
template<typename TKey, typename TValue>
class TPair : public System::TObject
{
public:
typedef System::TObject inherited;
private:
TKey FKey;
TValue FValue;
public:
TKey GetKey() const;
void SetKey(TKey key);
TValue GetValue() const;
void SetValue(TValue Value);
/*property key : TKey read GetKey write SetKey;*/
TKey ReadPropertykey() const { return GetKey();}
void WritePropertykey(TKey key){SetKey(key);}
/*property Value : TValue read GetValue write SetValue;*/
TValue ReadPropertyValue() const { return GetValue();}
void WritePropertyValue(TValue Value){SetValue(Value);}
TPair() {}
};
typedef TPair<System::String, int> TSIPair; // declares instantiated type
typedef TPair<System::String, System::String> TSSPair; // declares with other data types
typedef TPair<int, System::String> TISPair;
typedef TPair<int, int> TIIPair;
typedef TPair<System::String, TXMLNode> TSXPair;
template<typename TKey, typename TValue>
TValue TPair<TKey, TValue>::GetValue() const
{
TValue result;
result = FValue;
return result;
}
Deutsch
| Latest News |
|
10/28/24
Delphi2Cpp 2.5: Symbol names matching declaration case [more...] |
|
08/26/24
Delphi2Cpp 2.4: Updated to RAD Studio 12.1 Athens [more...] |
|
"Thanks for your great work, really appreciate the work you have done on zlib and compiling ... test case." Mattewada, Udayabhaskar
Nokia India
02/01/2021
|
|
[from case study...] "A masterpiece -- Delphi2Cpp has exceeded all my expectations by far." Tony Hürlimann
virtual-optima
08/20/2011
|
|
"First off, I have to say WOW! Delphi2Cpp is doing a *fantastic* job!" Daniel Flower
linkrealms
01/15/2011
|
|
This website is generated from plain text with [Minimal Website ]
|
Minimal Website
is made with TextTransformer
|
TextTransformer is made with Borland
CBuilder
|