title: Why does GCC need extra declarations in templates when VS does not?
body: <pre><code>template&lt;typename T&gt;
  class Base
  {
  protected:
      Base() {}
      T&amp; get() { return t; }
      T t;
  };
  
  template&lt;typename T&gt;
  class Derived : public Base&lt;T&gt;
  {
  public:
      Base&lt;T&gt;::get;                    // Line A
      Base&lt;T&gt;::t;                      // Line B
      void foo() { t = 4; get(); }
  };
  
  int main() { return 0; }
  </code></pre>
  
  <p>If I comment out lines A and B, this code compiles fine under Visual Studio 2008.  Yet when I compile under GCC 4.1 with lines A and B commented, I get these errors:</p>
  
  <blockquote>
    <p>In member function ‘void Derived::foo()’:<br>
     error: ‘t’ was not declared in this scope<br>
     error: there are no arguments to ‘get’ that depend on a template parameter, so a declaration of ‘get’ must be available</p>
  </blockquote>
  
  <p>Why would one compiler require lines A and B while the other doesn't?  Is there a way to simplify this?  In other words, if derived classes use 20 things from the base class, I have to put 20 lines of declarations for every class deriving from Base!  Is there a way around this that doesn't require so many declarations?</p>