title: Creating and storing objects in a container without using new?
body: <p>Say I have the class</p>
  <pre><code>class A{
     int value;
  public:
     A(int val) : value(val) {};
  }
  </code></pre>
  <p>I store pointers of instances in a collection such as vector using for loop</p>
  <pre><code>std::vector&lt;A*&gt; myCollection;
  for (int i = 0; i &lt; 10; ++i){
     myCollection.push_back(&amp;A(i));
  }
  </code></pre>
  <p>Now the for loop will construct and destruct an object at the same memory location resulting in a vector with 10 pointers pointing to the same address and dereferencing them will give A-&gt;value = 9.
  Is there any way around this without dynamic allocation? And yes I have to use collection of pointers and not references.</p>