title: Derived template-class access to base-class member-data
body: <p>This question is a furtherance of the one asked in <a href="https://stackoverflow.com/questions/1117693/initializing-template-base-class-member-types-in-derived-class-initializer-lists">this thread</a>.</p>
  
  <p>Using the following class definitions:</p>
  
  <pre><code>template &lt;class T&gt;
  class Foo {
  
  public:
      Foo (const foo_arg_t foo_arg) : _foo_arg(foo_arg)
      {
          /* do something for foo */
      }
      T Foo_T;        // either a TypeA or a TypeB - TBD
      foo_arg_t _foo_arg;
  };
  
  template &lt;class T&gt;
  class Bar : public Foo&lt;T&gt; {
  public:
      Bar (const foo_arg_t bar_arg, const a_arg_t a_arg)
      : Foo&lt;T&gt;(bar_arg)   // base-class initializer
      {
  
          Foo&lt;T&gt;::Foo_T = T(a_arg);
      }
  
      Bar (const foo_arg_t bar_arg, const b_arg_t b_arg)
      : Foo&lt;T&gt;(bar_arg)
      {
          Foo&lt;T&gt;::Foo_T = T(b_arg);
      }
  
      void BarFunc ();
  
  };
  
  template &lt;class T&gt;
  void Bar&lt;T&gt;::BarFunc () {
      std::cout &lt;&lt; _foo_arg &lt;&lt; std::endl;   // This doesn't work - compiler error is: error: ‘_foo_arg’ was not declared in this scope
      std::cout &lt;&lt; Bar&lt;T&gt;::_foo_arg &lt;&lt; std::endl;   // This works!
  }
  </code></pre>
  
  <p>When accessing the members of the template-class's base-class, it seems like I must always explicitly qualify the members using the template-style syntax of <code>Bar&lt;T&gt;::_foo_arg</code>. Is there a way to avoid this? Can a 'using' statement/directive come into play in a template class method to simplify the code?</p>
  
  <p><b>Edit:</b><p>
  The scope issue is resolved by qualifying the variable with this-> syntax.</p>