F
freegnu
how to declare a friend function that can access two class
it will look like the following
class A
{
private:
int i;
public:
A(){}
~A(){}
friend void call(A &a, B &b);
};
class A
{
private:
int j;
public:
B();
~B()
friend void call(A &a, B &b);
};
void call(A &a, B &b)
{
cout << a.i << endl << b.j <<endl;
}
it will look like the following
class A
{
private:
int i;
public:
A(){}
~A(){}
friend void call(A &a, B &b);
};
class A
{
private:
int j;
public:
B();
~B()
friend void call(A &a, B &b);
};
void call(A &a, B &b)
{
cout << a.i << endl << b.j <<endl;
}