title: Create a new object from existing pointer C++
body: <p>I've looked for the answer but still can't figure this out.</p>
  
  <p>Sorry, but my work is too complex to copy here sample code.</p>
  
  <p>I have a function, which gets a pointer as parameter; I use it, but later, I need a kind of callback, where I want to use my old pointed object.</p>
  
  <p>The problem is, when this callback is invoked, the pointer has already been deleted or freed. My idea was to make a copy of the pointed object on the heap, and free it when callback is finished. But I got lost between pointers, copy constructors and other stuff. The solution is probably quite simple, but I'm stuck.</p>