(Gast)
n/a Beiträge
|
Re: Object teilweise kopieren
2. Jun 2005, 10:55
Delphi-Quellcode:
type
ICloneable = interface
function Clone: TObject;
end;
type
TDeineKlasse = class(TInterfacedObject, ICloneable)
private
FInteger: integer;
FString: string;
FDouble: double;
public
function Clone: TObject;
property AsInteger: integer read FInteger write FInteger;
property AsString: string read FString write FString;
property AsDouble: double read FDouble write FDouble;
end;
function TDeineKlasse.Clone: TObject;
begin
Result := TDeineKlasse.Create;
with TDeineKlasse(Result) do begin
AsInteger := Self.AsInteger; // oder Self.FInteger;
AsString := Self.AsString;
AsDouble := Self.AsDouble;
end;
end;
... so würd ichs machen
var
xClone: TDeineKlasse;
begin
xClone := TDeineKlasse(deineOriginalKlasse.Clone);
end;
öhm ja
|
|
Zitat
|