//Hello! I was studying classes with out tutorials and I had a doubt...
//this is a pointer that is inside any non-static member function to refer to the internal status of the class...
But in the example below I can't really understand completely what that means, it's a bit ambiguous (for me at least) in the tutorial...
CVector& CVector::operator= (const CVector& param)
{
x = param.x;
y = param.y;
return *this;// 1)
}
// 1)
/*
a) Is *this not a dereference of the pointer this?
a.1) Are we actually passing the object and not the pointer(?) => no, a reference! (?)
b) If we write "return this;",
it's the same thing of the return statement in the example? (if yes, why?)
c) We are returning an reference to the object of type CVector
(from where this function is called) for what reason?
If we apply the overloaded operator=,
what does it mean? (see example below)
*/
Yes, that's what I supposed: with ' *this ' we are returning the current object (in this case this is used to do it), but in my example the function that overloads the operator ' = ' returns a reference and not an object! Why, if a function is supposed to return a reference, can return an object, we do it with: *this