我需要this
在内部类中使用外部类的指针。
this
如果不保存指针,我不知道该怎么做。有替代方案吗?
class outerclass {
outerClass thisPointer;
outerclass () {
//
// NOTE: I am saving this pointer here to reference
// by the inner class later. I am trying to find
// a different alternative instead of saving this pointer.
//
thisPointer = this;
}
class innerClass {
void doSomething () {
//
// is there a way to reference the outter class
// without having to save the thisPointer from
// the outter class.
// NOTE someObject is a class outside of the
// outterclass control.
//
someObject.someMethod (thisPointer);
}
}
}