title: Issue with Overloading Assignment Operator
body: <p>So the issue I'm running into is in my c++ program, when I try and test the Assignment Operator that I overloaded. </p>
  
  <p>The statement:</p>
  
  <pre><code>cm6 = cm5;
  </code></pre>
  
  <p>should set cm6 equal to cm5, but the value of cm6 doesn't change. Here's my code:</p>
  
  <hr>
  
  <p><strong>Proj_11.h</strong></p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;iomanip&gt;
  
  using namespace std;
  
  class ComplexNumber
  {
      private:
          double _real;
          double _imaginary;
      public:
          ComplexNumber();
          ComplexNumber(double, double);
          ComplexNumber(ComplexNumber&amp;); 
          ComplexNumber operator+ (ComplexNumber);
          ComplexNumber operator- (ComplexNumber);
          ComplexNumber operator* (ComplexNumber);
          ComplexNumber operator/ (ComplexNumber);
          ComplexNumber operator= (ComplexNumber);
          bool operator== (ComplexNumber);
          friend ostream&amp; operator&lt;&lt; (ostream&amp;, ComplexNumber);
  };
  
  void Menu();
  </code></pre>
  
  <hr>
  
  <p><strong>Proj_11.cpp</strong></p>
  
  <pre><code>#include "Proj_11.h"
  
  //Global Constants
  const double NOTHING = 0.0;
  const double INVERSE = -1.0;
  const int CURRENCY_FORMAT = 2;
  
  void main()
  {
     Menu();
  }
  
  void Menu( )
  {
      // Create complex numbers to do arithmentic with
      ComplexNumber cm1(1, 2);
      ComplexNumber cm2(1, -2);
  
      // test addition operator
      ComplexNumber cm3 = cm1 + cm2;
      cout &lt;&lt; cm3 &lt;&lt; endl;
  
      // test subtraction operator
      ComplexNumber cm4 = cm1 - cm2;
      cout &lt;&lt; cm4 &lt;&lt; endl;
  
      // test multiplication operator
      ComplexNumber cm5 = cm1 * cm2;
      cout &lt;&lt; cm5 &lt;&lt; endl;
  
      // test division operator
      ComplexNumber cm6 = cm1 / cm2;
      cout &lt;&lt; cm6&lt;&lt; endl;
  
      // test assignment operator
      cm6 = cm5;
      cout &lt;&lt; cm6 &lt;&lt; endl;
  
      // test comparison operator
      if (cm1 == cm2) 
          cout &lt;&lt; "\nThey are equal.\n";
      else
          cout &lt;&lt; "\nThey are not equal.";
  
      ComplexNumber cm8(1, 2);
      if (cm1 == cm8) 
          cout &lt;&lt; "\nThey are equal.\n";
      else
          cout &lt;&lt; "\nThey are not equal.";
  
      system ("PAUSE");
  }
  </code></pre>
  
  <hr>
  
  <pre><code>ComplexNumber::ComplexNumber()
  {
      _real = 0.0;
      _imaginary = 0.0;
  }
  
  ComplexNumber::ComplexNumber(double initReal, double initImaginary)
  {
      _real = initReal;
      _imaginary = initImaginary;
  }
  
  ComplexNumber::ComplexNumber(ComplexNumber&amp; cmplx)
  {
      _imaginary = cmplx._imaginary;
      _real = cmplx._real;
  }
  
  ComplexNumber ComplexNumber::operator+ (ComplexNumber x)
  {
      double newReal = _real + x._real;
      double newImaginary = _imaginary + x._imaginary;
      ComplexNumber temp(newReal, newImaginary);
      return temp;
  }
  
  ComplexNumber ComplexNumber::operator- (ComplexNumber x)
  {
      double newReal = _real - x._real;
      double newImaginary = _imaginary - x._imaginary;
      ComplexNumber temp(newReal, newImaginary);
      return temp;
  }
  
  ComplexNumber ComplexNumber::operator* (ComplexNumber x)
  {
      double newReal = 0.0;
      double newImaginary = 0.0;
      //(a+b)*(c+d) = ac+bc+ad+bd
      newReal = newReal + (_real * x._real);
      newImaginary = newImaginary + (_imaginary * x._real);
      newImaginary = newImaginary + (_real * x._imaginary);
      newReal = newReal + (INVERSE * (_imaginary * x._imaginary) );
      ComplexNumber temp(newReal, newImaginary);
      return temp;
  }
  
  ComplexNumber ComplexNumber::operator/ (ComplexNumber x)
  {
      double newReal = 0.0;
      double newImaginary = 0.0;
      ComplexNumber conjugate(x._real, (INVERSE * x._imaginary));
      ComplexNumber numerator = (*this * conjugate);
      ComplexNumber denominator = (x * conjugate);
      newReal = numerator._real / denominator._real;
      newImaginary = numerator._imaginary / denominator._real;
      ComplexNumber temp(newReal, newImaginary);
      return temp;
  }
  
  ComplexNumber ComplexNumber::operator= (ComplexNumber x)
  {
      ComplexNumber temp(x._real, x._imaginary);
      return temp;
  }
  
  bool ComplexNumber::operator== (ComplexNumber x)
  {
      if ( (_real == x._real) &amp;&amp; (_imaginary == x._imaginary) )
      {
          return true;
      }
      else
      {
          return false;
      }
  }
  
  ostream&amp; operator&lt;&lt; (ostream&amp; out, ComplexNumber x)
  {
      out.setf(ios::fixed);
      out.precision(CURRENCY_FORMAT);
      if ( (x._real != NOTHING) &amp;&amp; (x._imaginary != NOTHING) )
      {
          if ( (x._real &gt; NOTHING) &amp;&amp; (x._imaginary &gt; NOTHING) )
          {
              out &lt;&lt; x._real &lt;&lt; " + " &lt;&lt; x._imaginary &lt;&lt; "i";
              return out;
          }
          else if ( (x._real &gt; NOTHING) &amp;&amp; (x._imaginary &lt; NOTHING) )
          {
              out &lt;&lt; x._real &lt;&lt; " - " &lt;&lt; (INVERSE * x._imaginary) &lt;&lt; "i";
              return out;
          }
          else if ( (x._real &lt; NOTHING) &amp;&amp; (x._imaginary &gt; NOTHING) )
          {
              out &lt;&lt; x._real &lt;&lt; " + " &lt;&lt; x._imaginary &lt;&lt; "i";
              return out;
          }
          else
          {
              out &lt;&lt; x._real &lt;&lt; " - " &lt;&lt; (INVERSE * x._imaginary) &lt;&lt; "i";
              return out;
          }
      }
      else if ( (x._real == NOTHING) &amp;&amp; (x._imaginary != NOTHING) )
      {
          out &lt;&lt; x._imaginary &lt;&lt; "i";
          return out;
      }
      else if ( (x._real != NOTHING) &amp;&amp; (x._imaginary == NOTHING) )
      {
          out &lt;&lt; x._real;
          return out;
      }
      else
      {
          out &lt;&lt; NOTHING;
          return out;
      }
  }
  </code></pre>