title: Template derived class of a template base class
body: <p>I need to define a template derived class of a template base class. The question has been asked and answered before (e.g. <a href="https://stackoverflow.com/questions/12895775/class-template-inheritance-c">here</a>), but the accepted solution gives me a compiler error. For example, this code:</p>
  
  <pre><code>template&lt;typename T&gt;
  class Base {
  protected:
      T i;
  };
  
  template&lt;typename T&gt;
  class Derived : public Base&lt;T&gt; {
  public:
      void f(){
          i = 1;
      }
  };
  
  int main(){
      Derived&lt;int&gt; d;
  }
  </code></pre>
  
  <p>give the following errors:</p>
  
  <pre><code>$ g++ test.cpp 
  test2.cpp: In member function ‘void Derived&lt;T&gt;::f()’:
  test2.cpp:11:9: error: ‘i’ was not declared in this scope
           i = 1;
           ^
  $ clang++ test2.cpp 
  test2.cpp:11:9: error: use of undeclared identifier 'i'
          i = 1;
          ^
  1 error generated.
  </code></pre>
  
  <p>So it seems like the derived class doesn't see the variable defined in the mother (tested with gcc 7.2.1 and clang 5.0.0). For sure I must be doing something wrong, but I can't figure out what, especially given the fact that in the accepted answer to the <a href="https://stackoverflow.com/questions/12895775/class-template-inheritance-c">question I linked</a> the derived class seems to see the 'counter' variable defined in the mother class.
  Thanks for the help.</p>