The following is a simplified version of some code.
struct Test {
Test( int &id ) : id( id ) {}
int &id;
};
struct B : Test {
B() : Test( a ) {}
int a;
};
Now, I'm aware that the parent, in this case Test would be created before the B object when a B object is created. Does that then mean that the a variable, being passed in to the Test constructor, does not yet have an address and is thus Undefined Behaviour? Or is this safe?
Just to clarify, the value of id is not used until after B is fully constructed.