On Wed, Jan 13, 2010 at 19:13, David Emerson <dle...@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
  public
    constructor Create; virtual;
    class function GetCode: Word; virtual;
    Code: Word;
    ...
  end;

constructor TMessage.Create;
begin
  Code := GetCode;
end;

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).
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to