[fpc-pascal] how to simulate abstract properties

Marc Santhoff M.Santhoff at web.de
Sun Aug 16 04:37:52 CEST 2009


Hi,

I'm searching for a way to have the compiler handle properties declared
inside an abstract base class as if they were methods.

With a declaration like this:

TBase = class
private
  function getA: integer; virtual; abstract;
public
  property A:integer read getA;
end;

TDerived = class(TBase)
private
  function getA: integer; override;
end;

TDerived2 = class(TBase)
private
end;

the compiler runs and throws no error. Fine, but this way every class
derived from TBase is in danger of calling an abstract method at
runtime. If at an instance of class ´╗┐TDerived2 the property A is read a
runtime error 211 is thrown.

What I want is to ensure not forgetting to override any method. The
compiler should stop on error when this happens.
How can this be done?

(I know the compiler does emit a warning, but switching to "stop on
warning" is o option for me.)

TIA,
-- 
Marc Santhoff <M.Santhoff at web.de>




More information about the fpc-pascal mailing list