Hello..
Could someone explain me this:
Code:class someclass_1 {
public:
class someclass_2;
friend class someclass_2;
...
};
class someclass_1::someclass_2 {
public:
friend someclass_1;
...
};
Thanks a lot for help
Printable View
Hello..
Could someone explain me this:
Code:class someclass_1 {
public:
class someclass_2;
friend class someclass_2;
...
};
class someclass_1::someclass_2 {
public:
friend someclass_1;
...
};
Thanks a lot for help
if you want to make the class someclass_2 the friend class of the someclass_1, you must declare it first, otherwise the compiler will not know what the someclass_2 is.
but in someclass_2, you can just write the friend someclass_1 because the compiler knows what the someclass_1 which you have defined or declared looks like.
But why this:
Code:class someclass_1::someclass_2
because of this
someclass_2 is a member of the someclass_1Code:class someclass_1 {
public:
class someclass_2;
Oh, sorry, i didn't see it clearly.Quote:
Originally Posted by l2u
the someclass_2 is a member of the smoeclass_1 because you declare it in the someclass_1, so when you define the someclass_2,you must write it like the style you posted.
So someclass_2 is declared only for someclass_1 ?