Referencing the calling object?
I would just like to know if it's possible to reference the calling object in a member function as an object and not just by it's member data.
For this you got the "this" pointer. this will be available in all non-static methods.
1 2 3 4 5 6
|
void MyClass::doSomething()
{
std::cout << "Address to the calling object: " << this << std::endl;
this->anotherFunction();
(*this).anotherFunction();
}
|
Maikel
Man, I already tried that and the compiler complained about it. But, yeah, it works now, thank you.
Topic archived. No new replies allowed.