B
bipod.rafique
Hello All,
I have the following two classes:
class testb{
private:
int b;
public:
void friend_of_testa();
};
class testa{
friend void testb::friend_of_testa();
private:
int a;
};
Here, testb's member function friend_of_testa() is a friend of testa.
So private member of testa (say int a), is accessible from testb's
friend_of_testa. This is all good.
But what if I wanted a member function of testa be a friend of class
testb as well? like the following:
class testa; //forward reference
class testb{
friend void testa::friend_of_testb();
private:
int b;
public:
void friend_of_testa();
};
class testa{
friend void testb::friend_of_testa();
private:
int a;
public:
void friend_of_testb();
};
This is not possible as testa's friend_of_testb() is unknown to the
compiler at the time of testb's class declaration.
I know I would need a forward reference for testa before testb can use
it. But how do make testa's friend_of_testb() a forword reference for
the above to work?
Thanks
Bipod
I have the following two classes:
class testb{
private:
int b;
public:
void friend_of_testa();
};
class testa{
friend void testb::friend_of_testa();
private:
int a;
};
Here, testb's member function friend_of_testa() is a friend of testa.
So private member of testa (say int a), is accessible from testb's
friend_of_testa. This is all good.
But what if I wanted a member function of testa be a friend of class
testb as well? like the following:
class testa; //forward reference
class testb{
friend void testa::friend_of_testb();
private:
int b;
public:
void friend_of_testa();
};
class testa{
friend void testb::friend_of_testa();
private:
int a;
public:
void friend_of_testb();
};
This is not possible as testa's friend_of_testb() is unknown to the
compiler at the time of testb's class declaration.
I know I would need a forward reference for testa before testb can use
it. But how do make testa's friend_of_testb() a forword reference for
the above to work?
Thanks
Bipod