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
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.
Last edited by zouyu1983; 12-01-2006 at 11:17 AM.
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;
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
Oh, sorry, i didn't see it clearly.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.
Hello, guys, i come from china, so i am not good at english. If you find the sentence i wrote full of mistakes, please tell me.
I confirm that my english and programming skills will be improved with your help in this forum. thanks^_^
So someclass_2 is declared only for someclass_1 ?