I am reading a C++ tutorial book and it had this
what does "this" mean?Code:m_pGameEngine = this;
Printable View
I am reading a C++ tutorial book and it had this
what does "this" mean?Code:m_pGameEngine = this;
can you give us a little bit of context? (the full code, or the whole class or something?)
"this" is a reference to the object the code is currently running in. So if you're writing a function that's a member of the "GameEngine" class, "this" refers to the instance of GameEngine that the function was called on.
It's often useful when you might be dealing with two instances of the same class and you need to be unambiguous, or just for anytime you want to pass that specific instance somewhere else.Code:myGameEngine.doSomething(); // in the code for the doSomething() function, 'this' would be the 'myGameEngine'
Thanks