Which is better: storing objects vs storing pointers? : <p>I want to store elements (let's call it E), but I don't know that I should store them as objects or as pointers pointing to the dynamically allocated objects.</p>

<p><em>(A,B,C,etc. objects store the reference of the wanted E)</em></p>

<p><strong>version A:</strong></p>

<pre><code>E e;
store.Add(e); //This time the store contains objects.
</code></pre>

<p>In this version the element will be copied to the store, but it's easier to handle. (The objects will be destroyed when the parent object is destroyed)</p>

<p><strong>version B:</strong></p>

<pre><code>E* e = new E();
store.Add(*e); //This time the store contains references.
/*I chose references instead of pointers, 
so I have to use pointers only at allocating and deallocating.*/
</code></pre>

<p>In this version there is no copy constr. but I have to delete the objects in the parent object's destructor.</p>

<p>Which is better and why? Which can cause more mistakes and which is more efficient?</p>
