I’ve got the following classes:
class A {
// Whatever
};
class B {
T attribute;
A a;
};
Now suppose i have the following scenario:
A aX, aY;
B bX, bY;
Now i can sort of “insert” aX or aY into bX or bY.
I would like for the objects of type A to know, what B they are in, or in other words, what is the “attribute” of their “superclass” B.
Question:
I would like to be able to move the objects of type A freely between their “superclasses” B and i need a way to leak the attribute of B to them dynamically at runtime, so the objects of type A always know, what B they belong to (or what is the attribute of B they are currently in).
What is the best way to do it ?
Perhaps this is useful (pointer from the owner to the attribute, and the reverse):
UPDATED: Fixed a bug in cycle-pointing and cycle-calling, it could be solved only with a friend function.