can someone explain the this in the class ? i havent yet understood what it does
can someone explain the this in the class ? i havent yet understood what it does
this is a pointer to the invoking object. It is used often in overloaded-operator functions that need to return the object for stringing (i.e. n op m op r => n.op(m).op(r) ).
This is why in your previous code, *this was used. That is the actual instance of the invoking object.
yes but i need a good example :D
If you have
myClass obj[10];
And you invoke
obj[5].func();
Then the this pointer is the thing which tells you that it's obj[5] that needs to be updated, and not something else.