This surprised me. This works:
struct foo {
int x;
friend int x(foo f) { return f.x; }
friend int y(foo f);
};
int y(foo f) { return x(f); } // no problem
But this is an error:
struct foo {
int x;
friend int x(foo f) { return f.x; }
friend int y(foo f) { return x(f); } // error: invalid use of foo::x data member
};
Why aren't both of these (dis)allowed?