Good day It does not work out with one example.
void fnc(); class CLASS1 { public: int r; }; class CLASS2 : private CLASS1 { friend void fnc(); }; class CLASS3 : public CLASS2 { }; void fnc() { CLASS3 cl3; CLASS1 cl1; cl1 = cl3; } int main() {}
There are no compilation errors on VS2008, however, if CLASS3 is not inherited as public, but as protected, an error occurs that the conversion is not available. Remove friend - also not available. In the book, Lippman says that it is available if you can access the public field of the class to which the conversion is going, but in CLASS3 the base class (CLASS1) is not available (because CLASS2 inherits private), but the conversion is. How does a friend affect this and in general, how in such a situation does the compiler determine whether a conversion is available or not?
Sincerely, Victor