// file my_complex.h
class my_complex
{
public:
  my_complex(double r, double i);

  double& real()      { return r; }
  double& imaginary() { return i; }
  my_complex& add(double r, double i);
  my_complex& operator++();
  my_complex  operator++(int);
private:
  double r;
  double i;
};

// file my_complex.cpp
//#include "my_complex.h"

my_complex::my_complex(double r, double i) : r(r), i(i) { }

// returns reference the original object
my_complex& my_complex::add(double r, double i) {
  this->r += r;
  this->i += i;
  return *this;
}

// returns reference to the original (incremented) object
my_complex& my_complex::operator++() {
  r += 1;
  return *this;
}

// returns value with copy of the temporary object before incrementation
my_complex  my_complex::operator++(int) {
  my_complex orig(*this);
  r += 1;
  return orig;
}

// file main.cpp
int main()
{
  my_complex c(6, 5);       // default ctor
  double i = c.imaginary(); // copy returned reference
  c.real() = 8;             // modify through returned reference
  ++(c.add(3, 4));          // chaining function calls on 'c'
  my_complex d = c++;       // copy returned value
  return 0;
}