ich hatte das eigentlich so gedacht:
Delphi-Quellcode:
UNIT UContainer;
INTERFACE
USES
SysUtils;
TYPE
TContainer=Class
Private
FFileName:
String;
Public
class function Build(
const FName:
String;AsReadOnly:Boolean) : TContainer;
Constructor Create(
const FName:
String;AsReadOnly:Boolean);
Destructor Destroy;
override;
Property FileName:
String Read FFileName;
End;
IMPLEMENTATION
class function TContainer.Build(
const FName:
String;AsReadOnly:Boolean) : TContainer;
begin
if FileExists( FName )
then
Result := TContainer.Create( FName, AsReadOnly )
else
Result :=
nil;
end;
Constructor TContainer.Create(
const FName:
String;AsReadOnly:Boolean);
Begin
inherited Create;
FFileName := FName;
// ...
End;
Destructor TContainer.Destroy;
Begin
inherited Destroy
End;
END.
Aufruf:
Delphi-Quellcode:
var
Container : TContainer;
begin
Container := TContainer.Build( 'foo.txt', False );
if Assigned( Container ) then
begin
end;
end;
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ea 0a 4c 14 0d b6 3a a4 c1 c5 b9
dc 90 9d f0 e9 de 13 da 60)