On Thu, 30 Mar 2017, African Wild Dog wrote:
Hello,
1 - What happens if my constructor raise an exception? Is my destructor
automatically called?
Yes.
2 - Are the class fields automatically initialized to Default(T) just like
in Delphi?
Yes. The're zeroed out when the memory for the class is allocated.
Just run the following program. You can add a field and print the contents
in the destructor.
{$mode objfpc}
{$h+}
uses sysutils;
Type
TA = Class(TObject)
constructor create;
destructor destroy; override;
end;
Constructor TA.Create;
begin
Raise Exception.Create('aha');
end;
Destructor TA.Destroy;
begin
writeln('In destructor.');
end;
var
A : TA;
begin
A:=TA.Create;
end.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal