Why does the constructor allowed when operator overloading is returned?
Here is an example:
Complex Complex::operator*( const Complex &operand2 ) const { double Real = (real * operand2.real)-(imaginary * operand2.imaginary); double Imaginary = ( real * operand2.imaginary)+(imaginary * operand2.real); return Complex ( Real, Imaginary ); }
It seems the constructor for the object is returning, and not the object itself? What is coming back there?
This seems to make more sense:
Complex Complex::operator*( const Complex &operand2 ) const { double Real = (real * operand2.real)-(imaginary * operand2.imaginary); double Imaginary = ( real * operand2.imaginary)+(imaginary * operand2.real); Complex somenumber ( Real, Imaginary ); return somenumber; }
source share