Currently I am reading a book about C++
and it has some exercises. One of the exercises asks to build two classes where each has a friend method for another. My current guess looks like this:
#include <iostream>
using std::cout;
using std::endl;
class Y;
class X{
public:
void friend Y::f(X* x);
void g(Y* y){cout << "inside g(Y*)" << endl;}
};
class Y{
public:
void friend X::g(Y* y);
void f(X* x) {cout << "inside f(X*)" << endl;}
};
But my guess does not compile because class X
have void friend Y::f(X* x);
method declaration. How can I solve the puzzle? Give me some more guesses, please.