Date: Wed, 06 Nov 2019 18:05:19 +0300
In the paragraph #3 of the section "9.7.1.2 Namespace member definitions: there is the following example relative to friend function declarations.
namespace A {
class X {
friend void f(X); // A::f(X) is a friend
class Y {
friend void g(); // A::g is a friend
friend void h(int); // A::h is a friend
// ::h not considered
friend void f2<>(int); // ::f2<>(int) is a friend
};
};
// A::f, A::g and A::h are not visible here X x;
void g() { f(x); } // definition of A::g
void f(X) { /* ... */ } // definition of A::f
//...
However the definition of the friend function g is incorrect because the friend function f is not yet visible
I think the definitions should be exchanged
void f(X) { /* ... */ } // definition of A::f
void g() { f(x); } // definition of A::g
With best regards,
(Vlad from Moscow)
You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or http://ru.stackoverflow.com
namespace A {
class X {
friend void f(X); // A::f(X) is a friend
class Y {
friend void g(); // A::g is a friend
friend void h(int); // A::h is a friend
// ::h not considered
friend void f2<>(int); // ::f2<>(int) is a friend
};
};
// A::f, A::g and A::h are not visible here X x;
void g() { f(x); } // definition of A::g
void f(X) { /* ... */ } // definition of A::f
//...
However the definition of the friend function g is incorrect because the friend function f is not yet visible
I think the definitions should be exchanged
void f(X) { /* ... */ } // definition of A::f
void g() { f(x); } // definition of A::g
With best regards,
(Vlad from Moscow)
You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or http://ru.stackoverflow.com
Received on 2019-11-06 09:07:39