//base class of all oh holy lawrd of shiny tit
class character{
private:
int level;
public:
character();//constructor
};
two classes derived from the base
class allies:public character
{
public:
allies():character(){};//constructor of first derived class
};
class enemy:public character{
public:
enemy():character(){};//constructor of first derived class
};
//derived from derived classes
class warrior:public allies{
public:
warrior():allies(){};//constructor
};
class demon:public enemy{
public:
demon():enemy(){};//constructor
};
//the real problem
class spy:public allies,public enemy
{
public:
spy();
};
So as you all can see there is a yo dawg situation or derivation of derivation with one being multiple inheritance .
here's what confuses me , the spy class is inherited both from enemy and allies as shown above now when you create an object of spy it will call the allies constructor and the enemy constructor , cool right ?
but allies will call the character constructor and enemy will call the character constructor too since character is the base of both allies and enemy so for one object we have two instances of the class character created , burden on memory or okay ? I admit this is a shitty example but consider the situtation in some hard core programming project where you gotta make the sleekest and fastest app .One thing more , so considering the above example there will be two 'level' variables since there will be two character objects which one the object of class spy use ? I know this is some really retarded situation that came in my mind , but well there is a possibilty of this being true , what should one do in this situation ? its like a dead end