Der folgende Code demonstriert die Übersetzung eines generischen Delphi Types nach 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;
}
english
| Letzte Neuigkeiten |
|
28.10.24
Delphi2Cpp 2.5: in Groß- und Kleinschreibung mit Deklarationen übereinstimmende Symbolnamen [more...] |
|
08/26/24
Delphi2Cpp 2.4: Aktualisiert auf RAD Studio 12.1 Athen [more...] |
|
[aus Fallstudie...] "Eine Meisterleistung -- Delphi2Cpp hat alle meine Erwartungen weit übertroffen." Tony Hürlimann
virtual-optima
29.08.2011
|
|
"Ich muss mich nochmal für deinen Einsatz und die Qualität deiner Arbeit bedanken, das ist absolut überdurchschnittlich ..." Gerald Ebner
Significant Software
22.01.2010
|
|
Diese Homepage ist aus einfachen Texten mit [Minimal Website ]generiert.
|
Minimal Website ist mit Hilfe des TextTransformers hergestellt.
|
Der TextTransformer ist gemacht mit dem Borland
CBuilder
|