title: C++ Instantiate class and add name to array/vector then cycle through update functions from the array
body: <p>I have a bunch of classes in a basic (and badly coded!) game engine that are currently instantiated in the code and have to have their individual update functions called. What I want to do is be able to create an instance of a class, pass the name to an array, and then subsequently cycle through the array to call the update functions of each class. I'm unsure as to whether or not this is an impossible or spectacularly stupid way of trying to manage objects, so please tell me if it is.</p>
  
  <p>So currently I might have manually instantiated Enemy class a couple of times:</p>
  
  <pre><code>Enemy enem1;
  Enemy enem2;
  </code></pre>
  
  <p>I then have to update them manually in the game loop:</p>
  
  <pre><code>enem1.update();
  enem2.update();
  </code></pre>
  
  <p>What method should I use to be able to spawn and destroy instances of the enemy class during gametime? Is it possible to populate an array with instantiated names and then do something like (and i'm aware this doesn't work);</p>
  
  <pre><code>array[x].update();
  </code></pre>
  
  <p>Then iterate through the names in the array?</p>
  
  <p>Anything that even points me in the right direction would be greatly appreciated!</p>