M
Morya
Hi,
I had a scenario where classes had two way composition (Already
present in a huge code. Wasn't introduced by me) something like this:
A {
public:
A ()
: b(*this)
{
}
private:
B b;
};
B {
public B (A aobj) : a(aobj) {}
private:
A a;
};
I believe this code is not valid (undefined behavior ??) as A is not
fully constructed when it is passed to B. I googled around but didn't
find a direct reference of such situation. Any hints? pointers ?
~Moh
I had a scenario where classes had two way composition (Already
present in a huge code. Wasn't introduced by me) something like this:
A {
public:
A ()
: b(*this)
{
}
private:
B b;
};
B {
public B (A aobj) : a(aobj) {}
private:
A a;
};
I believe this code is not valid (undefined behavior ??) as A is not
fully constructed when it is passed to B. I googled around but didn't
find a direct reference of such situation. Any hints? pointers ?
~Moh