title: Accessing inherited variable from templated parent class
body: <p>Consider the following code:</p>
  
  <pre><code>template&lt;class T&gt; class Foo
  {
  public:
    Foo() { a = 1; }
  
  protected:
    int a;
  };
  
  template&lt;class T&gt; class Bar : public Foo&lt;T&gt;
  {
  public:
    Bar() { b = 4; };
  
    int Perna(int u);
  
  protected:
    int b;
  
  };
  
  template&lt;class T&gt; int Bar&lt;T&gt;::Perna(int u) 
  { 
    int c = Foo&lt;T&gt;::a * 4; // This works
    return (a + b) * u;    // This doesn't
  }
  </code></pre>
  
  <p>g++ 3.4.6, 4.3.2 and 4.1.2 give error </p>
  
  <pre><code>test.cpp: In member function `int Bar&lt;T&gt;::Perna(int)':
  test.cpp:25: error: `a' was not declared in this scope
  </code></pre>
  
  <p>g++ 2.96 and MSVC 6, 7, 7.1, 8 and 9 accept it, as do (at least) older Intel and SGI c++ compilers. </p>
  
  <p>Do the new Gnu C++ compiler obey the standard or not? If they do, what is the rationale behind that inheriting class is not able to see a protected inherited member variable?</p>
  
  <p>Also, if there's</p>
  
  <pre><code>int A() { return a; } 
  </code></pre>
  
  <p>in Foo, I get error</p>
  
  <pre><code>test.cpp:25: error: there are no arguments to A that depend on a template parameter, so a declaration of A must be available
  test.cpp:25: error: (if you use -fpermissiveâ, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
  </code></pre>
  
  <p>when I try to use it in a member function of Bar.
  I find that curious as well: Bar inherits Foo, so I think it's obvious that A() in scope of Bar is Foo::A().</p>