I need to use this pointer from the outer class in the inner class.
I don’t know how to do it without saving the this pointer. Is there an alternative?
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);
}
}
}
Use the syntax
NameOfOuterClass.this: