Marc Santhoff wrote:

the compiler runs and throws no error. Fine, but this way every class

Because you did not instantiate any instances of that class. Here is the output after compiling my sample program with FPC 2.2.5

===============================
$ fpc test1.pas
Free Pascal Compiler version 2.2.5 [2009/05/28] for i386
Copyright (c) 1993-2008 by Florian Klaempfl
Target OS: Linux for i386
Compiling test1.pas
test1.pas(31,24) Warning: Constructing a class "TDerived2" with abstract methods
Linking test1
35 lines compiled, 0.1 sec
1 warning(s) issued
===============================

It clearly shows the error, which is correct. Just declaring a class with abstract methods doesn't mean the compiler must throw an error. TDerived2 might have another class deriving from it, which adds the getA implementation.

As far as I can see, the compiler is doing everything correctly.

===========[ complete sample application ]==================
program test1;

{$mode objfpc}{$H+}

type
   TBase = class(TObject)
   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)
   end;

function TDerived.getA: integer;
begin
  result := 99;
end;

var
  a: TDerived;
  b: TDerived2;
begin
  a := TDerived.Create;
  b := TDerived2.Create;

  a.Free;
  b.Free;
end.
==================[ end ]=======================


Regards,
  - Graeme -

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to