[fpc-pascal] WHY compiler should be public?

Sven Barth pascaldragon at googlemail.com
Sun Oct 27 13:27:15 CET 2013


Am 27.10.2013 12:18 schrieb "Michael Van Canneyt" <michael at freepascal.org>:
>> Also,
>>  I don't understand why this does not work:
>>
>> f := TFileStream.Create;
>>
>> I know that TFileStream's Create require a file name parameter, but as
TFileStream is inherited from TObject, which has a Create without
parameter.  This is why I feel that it is possible to HIDE a public
>> constructor from ancestor.
>
>
> I think this is a bug :)

No, I don't think so. If you want users to use the original constructor as
well you'd need to declare yours as "overload". If it would be possible to
call TFileStream.Create without parameters then the instance would be in an
inconsistent state, so only calling the constructor with arguments should
be possible (which is the case for TFileStream.

So this is definitely by design.

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


More information about the fpc-pascal mailing list