I'm stuck with some issue, and google isnt helping.
Lets say we got parent "class BaseSpell". Aswell as we got child class "class CombatSpell : public Event, public BaseSpell".
Later we declare an object of base class:
BaseSpell* spell;
I always thought that parent class cannot contain child class(or its gonna take only those elements which are same in parent&&child). But later I saw such action:
CombatSpell* combatSpell = new CombatSpell(NULL, needTarget, needDirection);
spell = combatSpell;
And seems its actually working like I never expected, BaseSpell* spell contains fully working CombatSpell object. Can someone explain me, if thats true? Means object of parent class(BaseSpell in my case), can contain any child class(CombatSpell in my case)?
Lets say we got parent "class BaseSpell". Aswell as we got child class "class CombatSpell : public Event, public BaseSpell".
Later we declare an object of base class:
BaseSpell* spell;
I always thought that parent class cannot contain child class(or its gonna take only those elements which are same in parent&&child). But later I saw such action:
CombatSpell* combatSpell = new CombatSpell(NULL, needTarget, needDirection);
spell = combatSpell;
And seems its actually working like I never expected, BaseSpell* spell contains fully working CombatSpell object. Can someone explain me, if thats true? Means object of parent class(BaseSpell in my case), can contain any child class(CombatSpell in my case)?
Last edited: