Firstly I'll show you few classes.
class A {
public:
B * something;
void callSomething(void) {
something->call();
}
};
class B {
public:
A * activeParent;
B(A * parent) {
activeParent = parent;
}
void call(void) {
activeParent->something = new C;
}
};
class C : public B {
public:
A * activeParent;
C(A * parent) {
activeParent = parent;
}
void call(void) {
// do something
}
};
A * object;
object = new A;
object->something = new B;
object->callSomething();
My app needs such a structure. When I do callSomething(), it calls B's call() but when B's call() changes the "something" to C, C's call() is triggered and I want to avoid that. How should I do?