Wednesday, 21 August 2013

Can 'this' pointer be different than the object's pointer?

Can 'this' pointer be different than the object's pointer?

I've recently came across this strange function in some class:
void* getThis() {return this;}
And later in the code it is sometimes used like so: bla->getThis() (Where
bla is a pointer to an object of the class where this function is
defined.) And I can't seem to realize what this can be good for. Is there
any situation where a pointer to an object would be different than the
object's 'this'? (where bla != bla->getThis())
It seems like a stupid question but I wonder if I'm missing something here..

No comments:

Post a Comment