title: Dynamic creation of objects and adding them to a linked list
body: <p>It's about a C++ console game with tanks that shoots shells. The problem is about the tank shell part.
  I want to create an object of class PlayerTankShell and add it to a linked list every time the space button is pressed. How can i do that ?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;conio.h&gt;
  #include &lt;list&gt;
  
  using namespace std;
  
  #define ATTACK  32
  
  class PlayerTankShell
  {
      int x;
      int y;
      int speed;
      bool isExist;
  
  public:
      PlayerTankShell(bool exists)
      {
          isExist = exists;
      }
      bool getExistense()
      {
          return isExist;
      }
  };
  
  int main()
  {
      char input;
      input = getch();
  
      if (input == ATTACK)
      {
          // Here create an object and add it to the linked list
      }
  
      // My test so far:
      PlayerTankShell *s1 = new PlayerTankShell(1);
      PlayerTankShell *s2 = new PlayerTankShell(1);
      PlayerTankShell *s3 = new PlayerTankShell(1);
  
      list&lt;PlayerTankShell&gt; listShells;
  
      listShells.push_back(*s1);
      listShells.push_back(*s2);
      listShells.push_back(*s3);
  
      list&lt;PlayerTankShell&gt;::iterator i;
  
      for (i = listShells.begin(); i != listShells.end(); i++)
      {
          cout &lt;&lt; "exists=" &lt;&lt; i-&gt;getExistense() &lt;&lt; endl;
      }
  
      return 0;
  }
  </code></pre>