I have a vector which stores things of type abilities, I have a subtype from abilities called power_stab. I'm trying to use push_back(power_stab] however... Well I'm new to using class hierarchy.
I suppose the question is, how would I push_back something of type power_stab to std::vector<abilities> abilities?
Here are the relevant classes:
Think a class as a box. The box contains some values. A derived class is a larger box that contains both the box of the base class and other values.
The vector stores boxes of fixed size. You can push_pack a power_stab object because power_stab IS-A abilities, but it will only make a copy of the abililties box. That is called slicing.
What you seek is polymorphism. Make the vector contain pointers like std::unique_ptr or std::shared_ptr.
PS. does the "abilities" on line 39 refer to the "abilities" or "abilities"? Even if the compiler would be okay with that, it sure looks ambiguous.