Declaring who our friend is
friend void massage (body &);
Here we declare the (fictitious) class “antibody” to be a friend of our class “body”, so any member function of the antibody class has access to our private and protected stuff.
Also, the (again fictitious) non-member function “massage” can access all of our body class. A non-member function is not a member function of any class (just as any function in F77 or C used to be).
class cube : public body {
friend ostream& operator<< (ostream&, cube &);
cube (const float, const Color &c);
Here we define the “non-member operator” operator<< (which is a function just like the “massage” from above) to be a friend of our class cube. This function has now access to all of our protected and private stuff. By the way, the cout object is of class “ostream”.