title: Delphi class variables
body: <p>I have the following code:</p>
  
  <pre><code>// irrelevant code ...
  
  type
    Zombie = class
    private
      ...
      Age : Integer;
      Alive : Boolean;
      TotalDeadZombies, TotalZombieAge : Double;
    public
      ...
      procedure ZombieGrow();
      procedure CheckIfDead();
      ...
      Function AvgLife() : Double;
    end;
  
  procedure Zombie.ZombieGrow();
  begin
    ...
    if (Alive = false) then
    begin
      TotalDeadZombies := TotalDeadZombies + 1;
      TotalZombieAge := TotalZombieAge + Age;
    end;
  end;
  
  procedure Zombie.CheckIfDead();
  begin
    if Random(100) &lt; 20 then
      Alive := False;
  end;
  
  function Zombie.AvgLife() : Double;
  begin
    Result := TotalZombieAge / TotalDeadZombie;
  end;
  </code></pre>
  
  <p>The problem I have is I want to display the average age of dead zombies. This would be done via something like :</p>
  
  <pre><code>Write('Average age '+Floattostr(Round(AvgLife)))
  </code></pre>
  
  <p>However, this is called in another class (not shown here), and from my understanding of OOP, it would require me to specify an instantiated object, e.g <code>zombies[1].AvgLife</code> if they were stored in, say, a <code>Zombies[]</code> array (just an example).</p>
  
  <p>Is there a way of making it so the variables <code>TotalDeadZombies</code> and <code>TotalZombieAge</code> are not tied to any instantiated zombies, but rather to a class variable that I can then just call <code>AvgLife</code> somehow?  Is it as simple as just making them global variables? Or can it be done another way?</p>