I think the problem was that VC++ didn't allow friend functions to be defined in the body of declarations in .h files.