[fpc-pascal] abstract classes

Leonardo M. Ramé martinrame at yahoo.com
Mon Jan 21 23:28:28 CET 2013

> From: Howard Page-Clark <hdpc at talktalk.net>
>To: FPC users list <fpc-pascal at lists.freepascal.org> 
>Sent: Sunday, January 20, 2013 8:37 PM
>Subject: [fpc-pascal] abstract classes
>FPC allows the Delphi-compatible "class abstract" syntax, but does not seem to prevent instantiation of such a class.
>The following code compiles and runs satisfactorily (FPC version 2.6.0)
>Does trunk prevent this compiling?
>program Project1;
>{$mode objfpc}{$H+}
>  TAbstractClass = class abstract
>   class function GetID: integer; static;
>  end;
>class function TAbstractClass.GetID: integer;
>  Result:= 10;
>  ac: TAbstractClass;
>  ac:= TAbstractClass.Create;
>  WriteLn(ac.GetID);
>  ReadLn;
>  ac.Free;

As far as I remember Delphi has the same behavior.

Leonardo M. Ramé

More information about the fpc-pascal mailing list