Working around what @kerrekSB suggested, add using A::name; to class B :
struct A { int name; }; template<typename T> struct C : T { using T::name; }; struct B : private A { using A::name; friend struct C<B>; };
your original example did not work, so class A is private to B and class C<B> is a friend of B , but when accessing the name element from the C<B> object, the line is using T::name; > creates a problem because class B does not have a name member in it. this is the search area that finds the name member when trying to access it through an object of class B
Edit:
Adding the use of A :: name to B fixes the problem, but publishes A :: name to everyone, while it should be visible only to a specific instance of the template, namely C
if in this case, just declare a statement using A::name; in a private section in class B ie
struct B : private A { protected: using A::name; public: friend struct C<B>; };
Mr. Anubis
source share