Since the syntax friend class B doesn't declare a member of the class A, it doesn't matter where you write it, class B is a friend of class A.

[via @Nawaz]