how can I do that? I thought of an method in the complex class which copies every variable of the basic object to the complex object, but that seems a little bit to inconvenient.
class Basic
{
//basic stuff
}
class Complex : public Basic
{
//more stuff
}
Basic * basicObject = new Basic();
//now "extending" basicObject and "cast" it to Complex type
//which means copy everything in basicObject to an complexObject
or something like:
Complex * complexObject = new Complex();
complexObject.getEverythingFrom(basicObject);
seems to be too inconvenient, because everytime I change the Basic class, I have to change this “copy” method too.
Define the values you want to share between the classes in protected section like so: