The *this pointer

Can someone show me an example of when using *this is useful please. Preferable code, and not an explanation, but doesn't need to be detailed or necessarily compilable.

Thanks.
You mean dereferencing this?
1
2
3
4
T &operator=(const T &){
    //...
    return *this;
}
Just about any function where you are doing anything with any value >_>

(this-> == (*this).)
But why return *this. Why not just return the object?
this points to the object that was passed as the this parameter. In these two calls, this points to A and has the same value as B:
A.f();
B->f();
Dereferencing a pointer to an object gets the object. *this is the object.
Ok, I see, thanks.
Topic archived. No new replies allowed.