title: Delphi Class variable per class
body: <p>I've added a class variables to the base class of a deep class hierarchy. It's an integer intended to count number of instances created per class type. But I've run into a problem.</p>
  
  <p>Given the example:</p>
  
  <pre><code>  TBaseClass = class
    private
      class var fCreated: integer;
    public
      class function NewInstance: TObject; override;  
    end;
  
    TDescendant = class(TBaseClass)
    end;
  
    ...
  
    class function TBaseClass.NewInstance: TObject;
    begin
      result := inherited NewInstance;
      inc(fCreated);
    end;
  </code></pre>
  
  <p>I assumed that I can use the class var to store the number of instances created <strong>per class</strong>, but this does not seem to be the case.</p>
  
  <p>Inspecting <code>TBaseClass.fCreated</code> returns same value as <code>TDescendant.fCreated</code>, changing one via inspector changes the other, so it behaves as if <code>fCreated</code> is a single global var.</p>
  
  <p>I expected <code>fCreated</code> to be maintained per class type, isn't that the point ? What am I missing ?</p>