I have this piece of a class:
class Complex{
friend double Re(const Complex &z);
friend double Im(const Complex &z);
public:
Complex();
Complex(const double &, const double &);
Complex &operator += (const Complex &);
private:
double real, imag;
};
with +=, *=, /= and -= defined as members, and +, -, * and / as non members, as usual.
The question is, is it okay to implement the operator overloading and member functions in terms of friend functions (using Re(z) and Im(z) functions), or implement those in terms of private variables (z.real and z.imag)?
Also, is it okay to define member functions in terms of other members functions or friends, or should they be self-contained? Something like: implement /= overload in terms of *= and conjugate() and modulus() functions, or implement it self-contained with private variables?