|
-
July 31st, 2003, 01:05 PM
#1
Junior Member
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 ublic B
{
};
the code works find
i only want to know the relationship and the concept of this friend function with inheritance
thanx in advance
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|