Tried the following which works.
template <typename T>
class A
{
T *_t;
public:
A(T *t) : _t(t) {}
void accessT()
{
_t->privateAccess();
}
};
class C {
void privateAccess()
{
cout << "private" << endl;
}
friend A<C>;
};
int main()
{
C c;
A<C> a(&c);
a.accessT();
return 0;
}
With the friend declaration, the template class can access the private methods of class C. I don't know where you went wrong.
Edit: Most container classes have some default template arguments for allocators and such. Make sure they match in your friend declaration.