title: Unwanted creation of object at same memory address
body: <p>I haven't been working with C++ for a long time and now I need to do some small "project".<br>
  I reviewed few topics trying to find solution for my problem with no results...<br></p>
  
  <p>Here is "pseudo-code" (<code>Pair</code> is my class):</p>
  
  <pre><code>Pair** pairs;
  </code></pre>
  
  <p>I get size of table from input and create table of pointers:</p>
  
  <pre><code>pairs = new Pair*[size];
  </code></pre>
  
  <p>I have a loop which creates some object and puts it's reference into table of pointers. More or less:</p>
  
  <pre><code>while (...)
  {
      Pair pair(...); // calling constructor, creating object type of Pair.
      pairs[i] = &amp;pair;
      i++;
  }
  </code></pre>
  
  <p>The <strong>problem</strong> is that <code>&amp;pair</code> is the same number everytime (every step of loop).
  Let's say the address of first created object is 1234.
  So with every step in loop it overrides this object at 1234. So each pointer in <code>pairs</code> points to the same address -> same object.
  I would like to force creating this object at new place in memory.</p>
  
  <p>I've been trying to put those objects into other table and then pass their reference to table of pointers:</p>
  
  <pre><code>Pair* clearPairs = new Pair[size];
  while (...)
  {
      clearPairs[i] = Pair(...);
      pairs[i] = &amp;clearPairs[i];
      i++;
  }
  </code></pre>
  
  <p>But problem still occurs.</p>
  
  <p>Any tips?, mistakes/errors in my code (or thinking)? Shall I implement some "copying constructor"?</p>