I just took a class in c++ and one of the things we learned how to do was create classes, throughout the semester we were always declaring the copy assignment with void like this (let's say we are making a fraction class) voidoperator=(const fraction &);
On the last day of class my professor told us that we shouldn't use void to declare the copy assignment and that we should learn it on our own after the semester ends.
So what is the proper way to declare the copy assignment?
What about for the move assignment, should we use void there too or not?
@dhayden, in the copy assignment do I return the fraction on the left side of the equals operator or the right side, they would be equal after I // do the assignment ? Or am I not understanding what you mean by return *this; ?
I read the article and it explains a lot I just don't understand what the const in front of the return type is there for if we decide to include it, what is it keeping constant when I write this const MyClass& operator=(const MyClass& rhs) as opposed to this MyClass& operator=(const MyClass& rhs)?