Friendship

It is important that all classes and functions declared as friends remain in the same header file as the friend declaration so that a sinister and/or incompetent user cannot hijack the friend name. Remember that a friend declaration doesn't apply only to the class or function you have supplied, but to anything with the same name. In order to prevent substitution of a class or function that may have unpredictable side effects on the private data, all friends of a class should exist in the same header. [1]

Specifying friends with qualified names doesn't offer that much more protection since a namespace can be spread over several files and there is no way to guarantee that the file containing the functions you have supplied is the one that has been included in the project. The only way to ensure that the intended names to which you have granted friendship are the ones that are used is to place them with the class definition and let the one-definition rule do the enforcement.