I have a class hierarchy as follows:
I create an object A. A a=new A();
Somewhere, later in the code, I want to create an object B, called b, and want to specifically assign the object a as its parent. Is there a way to do this in C++?
Normally, I would do something like this:
B b=new B();
B's constructor would make a call to A's constructor
But if i have a parent object already instantiated, is there a way to assign that particular object as a child object's parent at the time the child is instantiated?