[Lazarus] Best practices on using classes for subroutine libraries
Joao Morais
jcmoraisjr at gmail.com
Mon Apr 16 03:54:33 CEST 2012
On Sat, Apr 14, 2012 at 04:23, Frank Church <vfclists at gmail.com> wrote:
> Is it possible to make them virtual and override them or replace them
> in descendant classes?
======>>>======
{$mode objfpc}
type
tfooclass = class of tfoo;
tfoo = class
public
class function m1: string; virtual;
end;
tbar = class(tfoo)
public
class function m1: string; override;
end;
class function tfoo.m1: string;
begin
Result := 'tfoo';
end;
class function tbar.m1: string;
begin
Result := 'tbar';
end;
var
vclass: tfooclass;
begin
vclass := tfoo;
writeln('1: ', vclass.m1);
vclass := tbar;
writeln('2: ', vclass.m1);
end.
======<<<======
Joao Morais
More information about the Lazarus
mailing list