[fpc-pascal] Questions About Constructors

Sven Barth pascaldragon at googlemail.com
Sat Apr 1 00:25:03 CEST 2017


Am 31.03.2017 19:27 schrieb "African Wild Dog" <paintedlycaon at gmail.com>:
>
> 2017-03-30 4:25 GMT-03:00 Michael Van Canneyt <michael at freepascal.org>:
>>
>>
>>
>> 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.
>>
>
> Thanks for the clarification.
> I've issued #0031619  to add these details in the documentation.

Keep in mind however that the second behavior can be changed by overriding
TObject.NewInstance (the default implementation allocates the memory of the
class and zeroes it).

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20170401/eb81cb5e/attachment.html>


More information about the fpc-pascal mailing list