| <<< C++ Encapsulation Notes | Index | The rules of friendship >>> |
Sometimes
two classes need to work together.
or a free function wants to have access to private data of a class
For exampple,
class Point
{
friend class Window;
friend void print_point( Point* p );
friend void circle::set_radar_radius( Point* p );
//...
};
| <<< C++ Encapsulation Notes | Index | The rules of friendship >>> |