[fpc-pascal] FPC class syntax was extended to support delphi code

Aleksa Todorovic alexione at gmail.com
Wed Jan 13 20:55:12 CET 2010

On Wed, Jan 13, 2010 at 19:13, David Emerson <dle3ab at angelbase.com> wrote:
> d.2. wrt class methods, can they be virtual? (This strikes me as being
> closely related to d.1)

Definitely, yes! (and I believe that was available before class
vars/consts) I use this great feature for (de)serialization of
messages in my client/server communication:

  TMessage = class
    constructor Create; virtual;
    class function GetCode: Word; virtual;
    Code: Word;

constructor TMessage.Create;
  Code := GetCode;

So, when I want to create new message, I just call
TLoginMessage.Create or TChatMessage.Create or whatever (those classes
override GetCode, and everything works perfect).

More information about the fpc-pascal mailing list