I am building a c++ program for handling complex numbers.
I am having problem with the behaviour of this code:
Complex& Complex::operator=(const Complex& com)
{
Complex::re_=com.re_;
Complex::im_=com.im_;
return *this;
}
Now, the return type of this function is a reference of Complex type. So shouldn’t I be passing this rather than *this.
The
thispointer is the address of your object instance.Use an asterisk to dereference it.