title: Why am I getting the error 'A<int>' is not an accessible base of 'S<int>' for a base class's base class?
body: <p>I'm trying to call the class function <code>A&lt;F&gt;::f()</code> from within class <code>S</code>, but I'm getting the following errors when I instantiate an <code>S</code> object ( <code>S&lt;int&gt;s</code> ) and call it's <code>f</code> member function ( <code>s.f()</code> ) :</p>
  
  <blockquote>
    <p>source.cpp: In instantiation of '<code>int S&lt;F&gt;::f() [with F = int]</code>':<br>
    source.cpp:30:21: required from here<br>
    source.cpp:22:25: error: '<code>A&lt;int&gt;</code>' is not an accessible base of '<code>S&lt;int&gt;</code>'</p>
  </blockquote>
  
  <p>Note that this works when I replace <code>return A&lt;F&gt;::f();</code> inside the declaration of class <code>S</code> with <code>return C&lt;A, F&gt;::f();</code>. But I'm wondering why I can't do it the other way...</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  template &lt;typename T&gt; class A {
     public:
        int f();
  };
  
  template &lt;typename T&gt; int A&lt;T&gt;::f() {
     return sizeof(T);
  }
  
  template &lt;template &lt;typename&gt; class E, typename D&gt; class C : E&lt;D&gt; {
     public:
        int f() {
           return E&lt;D&gt;::f();
        }
  };
  
  template &lt;typename F&gt; class S : C&lt;A, F&gt; {
     public:
        int f() {
           return A&lt;F&gt;::f();
        }
  };
  
  int main() {
  
     S&lt;int&gt;s;
  
     std::cout &lt;&lt; s.f();
  
  }
  </code></pre>
  
  <p>Any help is appreciated and if you require further clarification please feel free to comment.</p>
  
  <p><strong>Update</strong></p>
  
  <p>Since this questions is resolved I guess I should post the code that actually worked:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  template &lt;typename T&gt; class A {
     public:
        int f();
  };
  
  template &lt;typename T&gt; int A&lt;T&gt;::f() {
     return sizeof(T);
  }
  
  template &lt;template &lt;typename&gt; class E, typename D&gt; class C : public E&lt;D&gt; {
     public:
        int f() {
           return E&lt;D&gt;::f();
        }
  };
  
  class S : public C&lt;A, int&gt; {};
  
  int main() {
  
     S s;
  
     std::cout &lt;&lt; s.f(); // 4
  
  }
  </code></pre>