title: Writing a deep copy - copying pointer value
body: <p>In writing a copy constructor for a class that holds a pointer to dynamically allocated memory, I have a question.</p>
  
  <p>How can I specify that I want the value of the pointer of the copied from object to be copied to the pointer of the copied to object. Obviously something like this doesn't work...</p>
  
  <pre><code>*foo = *bar.foo;
  </code></pre>
  
  <p>because, the bar object is being deleted (the purpose of copying the object in the first place), and this just has the copied to object's foo point to the same place. </p>
  
  <p>What is the solution here? How can I take the value of the dynamically allocated memory, and copy it to a different address?</p>