In my C++ book, I don't understand this particular example demonstrating operator overloading:
What I don't understand is the need to return *this. I know the function is specified as returning an object type 'ThreeD' but isn't that redundant? Would the following achieve the same thing:Code:ThreeD ThreeD :: operator=(ThreeD &op2) {
x=op2.x;
y=op2.y;
z=op2.z;
return *this;
}
Code:void ThreeD :: operator=(ThreeD&op2) {
x=op2.x;
y=op2.y;
z=op2.z;
return;
}