title: Why am I able to access private class variables from outside the class, and how can I prevent it?
body: <p>I am  using this code </p>
  
  <pre><code>type
   TSomeClass = class(TOBject)
   private
    class var InstanceCount : integer;
    class var TotalInstanceCount : integer;
   public
    class function instances: integer;
    class function totalInstances: integer;
    constructor Create;
    destructor Destroy;
  end;
  
  constructor TSomeClass.Create;
  begin
   inherited Create;
   Inc(InstanceCount);
   Inc(TotalInstanceCount);
  end;
  
  destructor TSomeClass.Destroy;
  begin
   Dec(InstanceCount);
   inherited;
  end;
  
  class function TSomeClass.instances;
  begin
    Result := InstanceCount;
  end;
  
  class function TSomeClass.totalInstances;
  begin
    Result := TotalInstanceCount;
  end;
  </code></pre>
  
  <p>I want to make an instance counter and I set some class variables as private. The question is very easy, just look at this picture:</p>
  
  <p><a href="https://i.stack.imgur.com/amAro.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/amAro.png" alt="enter image description here"></a></p>
  
  <p>As you can see in the red box, there are the class variables that I have declared as private. I don't want them to appear. I only want the public class functions to be able to show the counters. What can I do?</p>