Hello,
Consider this scenario,
Friend function is used to allow non-members to access private data defined inside a class. Now my question is I have two variables x and y in class A, and two variables i and j in class B. Is it possible that I can allow my users (outside class) to access only variable x and not y defined in class A ? Similarly, allow access outside class only to variable i and not to j in class B.Code:class B;
class A
{
private:
int x, y;
public:
A(){}
friend void func( A a, B b );
};
class B
{
private:
int i, j;
public:
B(){}
friend void func( A a, B b );
};
NOTE: The above scenario should happen only when friend is defined.
Thanks
