title: Making a vector of superclass type that can store subclass objects
body: <p>So I started a small little project to work on while I am learning. Basically, what I'm trying to do is a small "game" which I plan to build on as I learn new things.</p>
  
  <p>Here is a brief description and my problem.</p>
  
  <p>Basically, I want to assign various Hero types to a player based on their choice.</p>
  
  <p>I made a base class "Hero" with only a HP parameter so far. After that, I made 2 derived classes from Hero, HeroType1, HeroType2 which will have specific abilities and so on. </p>
  
  <p>I decided on storing various hero types in <code>std::vector&lt;Hero*&gt; Heroes</code>. Basically, I start my "game" by calling initializeHeroes function which, depending on the player choice creates a new object of type NewHero1 or NewHero2 and stores it an the vector mentioned before. The thing is, no matter what I tried so far, I can't access derived member functions when I want to use them later, only those of the Hero class. </p>
  
  <p>What feels like a good solution: declare global variables player1, player2 and assign to them after players choose the HeroType. However, I can't do that because the data type has to be known before compiling. Sorry if this is a stupid and basic question, my knowledge is still very limited and that is why I am asking for some hints here.</p>
  
  <p>I'd kindly like to ask on how would you approach this, I know it is a very simple issue, but I'm still a beginner and I'm trying to figure out the best way to solve this. Thanks in advance.</p>