pe****************@hotmail.com wrote:
Will the keyword "this" give me the address of the instance of the
class that called the class method which is using the keyword "this"?
Your phrase "the instance of the class that called the class method" is
not clear. Consider this:
struct A;
void Baz( A* ) {}
struct A
{
void Foo() { Baz( this ); } // Ok
};
struct B
{
void Bar( A& a )
{
a.Foo(); // Ok
Baz( this ); // Error
}
};
int main()
{
A a;
B b;
b.Bar( a );
}
In this example, the class instance that calls A::Foo() is an instance
of B. Within A::Foo(), "this" refers to an A object. Within B::Bar(),
"this" points to a B object, which is why the call to Baz generates an
error in B::Bar().
Cheers! --M