// COMPLEX NUMBER / OVERRIDE OPERATOR

#include <iostream>

using namespace std;

class Complex
{
  public:

    Complex();
    ~Complex();
    Complex( float re, float im );

    Complex ( Complex & c );

    Complex operator+( Complex & c);

    void print ();

    float real;
    float imag;

  private:

};

// ************************************************************************

Complex::Complex()
{
  real = 0.0f;
  imag = 0.0f;
}

Complex::~Complex()
{}

Complex::Complex( float re, float im )
{
  real = re;
  imag = im;
}

Complex::Complex( Complex & c )
{
  this->real = c.real;
  this->imag = c.imag;
}

Complex Complex::operator+( Complex & c )
{
  Complex cx ( this->real + c.real, this->imag + c.imag );
  return cx;
}

void Complex::print()
{
  cout << this->real << " + " << this->imag << "i" << endl;
}

// ************************************************************************

int main( int argv, char** argc )
{
  Complex c;
  c.real = 4;
  c.imag = 2;

  Complex cx ( 5, 4 );

  c.print();
  cx.print();

  Complex ans;

  ans = c + cx;

  ans.print();

  return 0;
}

// OUTPUT:
// 4 + 2i
// 5 + 4i
// 9 + 6i

// EOF