First, I am using as reference this excellent answer on this
and *this
.
Say I have a class:
class myclass{
myclass& dosomething(){
// do something here
return *this; //According to the referenced answer I am returning the same object
}
myclass& operator<<(myclass &mc){
return mc; // HERE, am I returning the same object??
}
};
int main(){
myclass myobject;
myobject << myobject.dosomething();
}
My question is, in the overload operator, I am passing a reference as aan argument, right? And I am returning the same object, is this correct?