[fpc-pascal]How to make a constructor failed?
mili
milimeter at 163.com
Thu Aug 22 23:23:55 CEST 2002
Hello, Every one
I intend to create my own class such as the following:
>>>>
type
TMyClass = class(TObject)
public
constructor Create(fn:String);
destructor Free;
end;//TMyClass
implementation
constructor TMyClass.Create(fn:String);
begin
if not FileExists(fn) then begin
// ---> Here I want to make the new object nil
end;
end;//TMyClass.Create
demo:
myclass:=TMyClass.Create('aaaa.txt');
if myclass=nil then exit;// ---> Here I can check if the object is valid
<<<<<<<<
Can you tell me what's the constructor should be like to implement this?
Thank you,
mili
More information about the fpc-pascal
mailing list