Thanks for the reply.

Quote Originally Posted by laserlight View Post
Because the code is broken: by right, the order of includes should not matter, but it does. Unfortunate, but it happens in real life.
Thanks for confirming that. I'll look to other books for better examples of 'Class Members as Friends'.


Quote Originally Posted by laserlight View Post
Anyway, the reason is that the friendship declaration does not declare CCarton as a friend of CBottle. Rather, it declares CCarton::CCarton as a friend of CBottle, hence the definition of CCarton must be available at that point. Thus, instead of the forward declaration of CCarton, CBottle.h should #include "CCarton.h".
So if I'm understanding you right, the CCarton class could be declared a friend of CBottle, and the defintion of CCarton wouldn't be required (forward declaration in place of the #include line?) yet?