title: Accessing public static members of a base class specified as private
body: <p>I'm learning C++. The documentation <a href="https://docs.microsoft.com/en-us/cpp/cpp/member-access-control-cpp" rel="noreferrer">docs.microsoft.com/en-us/cpp/cpp/member-access-control-cpp</a> says:</p>
  
  <blockquote>
    <p>When you specify a base class as private, it affects only nonstatic members. Public static members are still accessible in the derived classes.</p>
  </blockquote>
  
  <p>However, the following code slightly adjusted from the example following the previous quote cause error C2247: </p>
  
  <blockquote>
    <p>'Base::y' not accessible because 'Derived1' uses 'private' to inherit from 'Base'.</p>
  </blockquote>
  
  <p>I will appreciate any help with this situation.</p>
  
  <pre><code>class Base
  {
  public:
      int x;             
      static int y;      
  };
  
  class Derived1 : private Base
  {
  };
  
  class Derived2 : public Derived1
  {
  public:
      int ShowCount();    
  };
  
  int Derived2::ShowCount()
  {
      int cCount = Base::y;       
      return cCount;
  }
  </code></pre>