[fpc-pascal] virtual class var?

Paul Ishenin paul.ishenin at gmail.com
Tue Aug 7 05:02:24 CEST 2012


07.08.12, 8:18, Andrew Haines wrote:
> Hi, is it possible to have a virtual class variable? I want to have a
> pointer available per class that can be a different value.
> Something like this:
>
>    TA = class
>      class var Foo: TObject; virtual;
>    end;
>
>    TB = class(TA)
>      class var Foo: TSpecialObject; override;
>    end;

Class variable is stored the same way as a regular variable and has the 
only difference is that it can be accessible with the class name prefix. 
The thing you need requires different implementation - something like 
storing a virtual class variable in VMT. There is no implementation for 
that.

Best regards,
Paul Ishenin



More information about the fpc-pascal mailing list