While designing part of my game framework I came across a problem with templates and friend declarations within them. I've sumed up the problem into these few lines of code:
A class declares its friends, it doesn't declare what other classes it's friends of. In your code, you're not declaring C to be a friend of A; you're declaring A to be a friend of C. Friendship is a one-directional property. If A is a friend of C, then A has access to C's private members, but the opposite is not true. Making A a friend of C doesn't make C a friend of A.