My friend with my father !!

Hi All,

I have a class A. I inherit it to form a class B.
Now if I delcare B as a friend of another class C
What is the relation between A and C.
If B can use any function from A, can C too ??

I couldn't find any article on this particular relation.

~Cheers!
navderm
Compile and find out!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class C{
    int c;
public:
    void func();
};

class B{
    int b;
    friend class C;
};

class A : public B{
    int a;
};

void C::func(){
    A aa;
    aa.a = 5;
    aa.b = 7;
}

int main(){
    C cc;
    cc.func();
    return 0;
}
Topic archived. No new replies allowed.