Can I pass a pointer to a superclass, but create a copy of the child?

Posted by Alex on Stack Overflow See other posts from Stack Overflow or by Alex
Published on 2010-06-17T16:22:11Z Indexed on 2010/06/17 16:33 UTC
Read the original article Hit count: 160

I have a function that takes a pointer to a superclass and performs operations on it. However, at some point, the function must make a deep copy of the inputted object. Is there any way I can perform such a copy?

It occurred to me to make the function a template function and simply have the user pass the type, but I hold out hope that C++ offers a more elegant solution.

© Stack Overflow or respective owner

Related posts about c++

Related posts about polymorphism