C
craig
During construction of an object "parent", if you create a subobject
that stores a pointer to the parent (through the "this" pointer), will
that pointer be valid when the subobject is later called?
class Parent
{
Parent:
arent() { child = new Child( this) };
Child *child;
};
class Child
{
Child::Child( Parent *par) { myParent = par };
Parent *myParent;
}
Will myParent be the correct address when child is subsequently
accessed?
Any comments greatly appreciated.
Craig
that stores a pointer to the parent (through the "this" pointer), will
that pointer be valid when the subobject is later called?
class Parent
{
Parent:
Child *child;
};
class Child
{
Child::Child( Parent *par) { myParent = par };
Parent *myParent;
}
Will myParent be the correct address when child is subsequently
accessed?
Any comments greatly appreciated.
Craig