title: For a Nested class in C++ how do you access the private member of enclosed class?
body: <p>I am a beginner in C++, I had a question regarding nested class in C++, how do you access the  protected or private member of an enclosed class?</p>
  <pre><code>class A{
    
     class B{
         protected:
          B(){};
  
     };
     B var;  &lt;===  error as the constructor B is protected  
  };
  </code></pre>
  <p>One solution is making constructor of B public, but this exposes it'a scope and other function can instantiate it, which I don't want. What's a way to do deal with this ?</p>