Why is returning a constructor allowed in operator overloading?
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 to be returning a constructor for the object and not the object itself? What is it returning 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;
}