タイプ Foo のオブジェクトがある状況があります。このオブジェクトでは、独自のメソッドを呼び出すと、何らかの形で「this」内の独自のアドレスを追跡できなくなります。これらの関数を定義しました:
// Bar has an instance of foo, and wishes to call a function001()...
Bar::doThingWithFoo(){
// foo is at address 0x1a7bbb70 here...
foo->function001();
}
// The definition of function001(). The address of "this" is as expected.
Foo::function001(){
// the address of "this" is 0x1a7bbb70 here...
this->function002();
}
Foo::function002(){
// but the address of "this" is 0xbfffe090 here!!!
// bad things happen, as you might expect.
this->getMyProperty()->doThing();
}
なぜこのようなことが起こるのでしょうか?