friend A f();
This line declares that a function without a template A f()exists and is a friend of the class. This is not the same function as f<A>()- it is a completely new function.
friend B f();
This line declares another function without a template with the same name, but has a different return type. You cannot overload the return type of a function, so this is not allowed.
, - ; , , .
, , , :
class A {
friend A f<A>();
};
class B {
friend B f<B>();
};
, :
class A {
friend void f<A>(A);
};
class B {
friend void f<B>(B);
};