[fpc-pascal] FPC class syntax was extended to support delphi code
marc at dommelstein.net
Fri Jan 15 00:19:14 CET 2010
Paul Ishenin wrote:
> David Emerson wrote:
>> d. What happens with inheritance?
>> d.1. wrt class constants and class vars-- are there separate
>> "instances" (for lack of a better word) of these, one instance for
>> each descendant? Or is the class var/const only stored once for the
>> ancestor that declares it, and all descendants share that?
> Class vars (static class fields) are stored only once for the class
> which declares them and all descendants share that.
> TSomeClass = class
> class var Value: Integer;
> TDescendant = class(TSomeClass);
> TSomeClass.Value := 1;
> TDescendant.Value := 2;
> WriteLn(TSomeClass.Value); // this must output 2
> Class static field is not a new feature. But now you can declare them
> using 'class var' section after methods or 'type'/'const' section.
Can we have a virtual version too like described here
More information about the fpc-pascal