>>753
g++ でコンパイルすると、
:4: error: ISO C++ forbids declaration of `foo' with no type
:4: error: `foo' is neither function nor member function; cannot be declared friend

まぁそれは置いとくとして、
 friend class foo<T>;
で通ったよ。