Missing warning?

Missing warning?

type

  TMyClass = class abstract (TObject)

     // Lots of methods, but none of them abstract;

  end;

  TMyImplementedClass = class(TMyClass)

    // Overrides some of the parent methods and adds new ones

   end;

var

   TFoo: TMyClass;

begin

   TFoo := TMyClass.Create;  *// WHAT!? No Warnings!?*

 

The XE2 to XE7 documentation states…

http://docwiki.embarcadero.com/RADStudio/XE7/en/Classes_and_Objects

states “Note: Delphi allows instantiating a class declared abstract, for backward compatibility, but this feature should not be used anymore.” – which is all dandy, but not issuing a warning for such use, that seems wrong to me.

Interestingly, the XE version is different…

http://docwiki.embarcadero.com/RADStudio/XE/en/Classes_and_Objects

and says “If a class is marked abstract, then it cannot be instantiated directly using the Create constructor. “

When did they introduce this keyword – and why did they not stick with the XE design?  Go figure…

Is there a QP or QC for this?

13 thoughts on “Missing warning?


  1. Stefan Glienke – IMO, it needs to at least output a warning.  Isn’t the whole idea of an abstract class, that it simply is a “template” for actual implementations to inherit from?