Friend Function And Inheritance
[Code]
#include<iostream.h>
class B;
class A
{
int a;
public:
A()
{
a=1;
}
friend void FRIEND(A,B);
};
class B
{
int b;
B()
{
b=1;
}
friend void FRIEND(A,B);
};
class D: private B
{
};
void FRIEND(A x, B y)
{
int c=x.a+y+b;
cout<<c;
}
void main()
{
A x;
D y;
FRIEND(x,y);
}
The Above code gives these error
1. Cannot access B::B(D)
2. Cannot find Match for FRIEND(A,D);
if i change the Class D
As
class D:public B
{
};
the code works find
i only want to know the relationship and the concept of this friend function with inheritance
thanx in advance