Op 27/06/2019 om 23:56 schreef Ryan Joseph:
On Jun 27, 2019, at 5:53 PM, Ben Grasset <operato...@gmail.com> wrote:
If you specifically need inheritance (combined with virtual methods) you should
probably just use classes, because doing it with objects will require heap
allocation regardless.
Heap allocate how so? Calling the constructor seems to fix this and puts the
VMT table on the stack (I think anyways). Btw I’m doing this specifically as
testing for a possible “advancedobjects” mode switch and the only reason to use
objects is for inheritance on the stack (otherwise records or classes).
The core problem remains that if you have
var x : TA;
and somehow instantiate a TB in it (for virtual method/use
polymorphism), then the sizes of TA and TB must match.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal