Programming classes

The stand-alone function operator+ is a friend of the Complex class

class Complex
{
   ...
   friend Complex operator+ (const Complex& a, const Complex& b);
   ...
};

so it can read (and manipulate) the private data parts \( re \) and \( im \) via

inline Complex operator+ (const Complex& a, const Complex& b)
{ return Complex (a.re + b.re, a.im + b.im); }