So for example:
const Ball& operator=(const Ball& other) { // Irrelevant code return *this; } So I have heard that you return a reference to an object because of cascading:
Ball a,b,c; // Unimportant initializations a=b=c; But why can't the method be something like:
const Ball operator=(const Ball& other) { // Irrelevant code return *this; } Or this:
const Ball* operator=(const Ball& other) { // Irrelevant code return this; } What if I do something like:
Ball *a, *b, *c; // Unimportant initializations a = b; Would this work with both the methods I provided?
I apologize if these are dumb questions. I am still fairly new at C++. Any help would be nice.