[fpc-pascal] class declaration questions

Joao Morais post at joaomorais.com.br
Fri Oct 12 23:41:19 CEST 2007


Felipe Monteiro de Carvalho wrote:
> On 10/12/07, Marc Santhoff <M.Santhoff at t-online.de> wrote:
>> Does object pascal allow a class declaration marked as an abstract
>> class? Like in java for making sure the class can never be instantiated
>> itself, only it's descendants can be?
> 
> The compiler will issue a warning if you instantiate a class with
> abstract methods

Only if creating an instance straight from the class, eg:

This will warn:

begin
   VMyObj := TMyAbstract.Create;

This wont:

var
   VMyClass: TMyAbstractClass;
begin
   VMyClass := TMyAbstract;
   VMyObj := VMyClass.Create;

--
Joao Morais



More information about the fpc-pascal mailing list