title: C++ scope resolution operator vs friend for accessing parent's protected variables
body: <p>What is the right way to access a parent's protected variable?</p>
  
  <hr>
  
  <pre><code>template&lt;typename T&gt;
  struct A
  {
      A() : i(2) {}
  protected:
      int i;
  };
  </code></pre>
  
  <pre><code>template&lt;typename T&gt;
  struct B : public A
  {
      void foo() { std::cout &lt;&lt; A&lt;T&gt;::i &lt;&lt; std::endl; }
  };
  </code></pre>
  
  <hr>
  
  <p>This will correctly print out <code>2</code>. </p>
  
  <p>Is there another way to do it with inheritance?</p>
  
  <p>Should I instead of inheritance make <strong>B</strong> a friend?</p>