[fpc-pascal] Wrong constructor returning the right object
Jeppe Græsdal Johansen
jeppe at j-software.dk
Sun Feb 23 17:54:27 CET 2014
Den 23-02-2014 17:03, Mark Morgan Lloyd skrev:
> Marco van de Voort wrote:
>> In our previous episode, Mark Morgan Lloyd said:
>>
>> That logical, since the constructors are not an virtual; and
>> override; pair.
>>
>>> I find that if I explicitly decorate TB5500BaseUnit.Create() as
>>> virtual and TB5500SPOUnit.Create() as override then
>>> TB5500SPOUnit.Create() is called correctly.
>>
>> That's the normal way.
>>
>>> I didn't think this was necessary,
>>
>> _why_ did you think this?
>
> In part, because the documentation on method declarations at
> http://www.freepascal.org/docs-html/ref/refsu25.html#x66-730005.5.1
> explicitly allows a virtual method directive, but the documentation
> on constructor declarations at
> http://www.freepascal.org/docs-html/ref/refse28.html#x64-710005.4
> explicitly does not allow it.
That documentation is about objects, not classes.
Here's the relevant part for classes:
http://www.freepascal.org/docs-html/ref/refsu25.html#x66-730005.5.1
More information about the fpc-pascal
mailing list