B
bytebro
I have a function which is passed a pointer to a Base object, and I
would like to create a copy of the Derived object who's address was
passed in. I was hoping I could do something like this:
class Thing
{
private:
Base* ptr_;
Base* copyptr_
public:
Thing(Base* param) : ptr_(param), copyptr_(new Base(*param) {}
}
But of course this simply tries to create a new Base object which will
fail if Base has any pure virtual functions. Is there some way of
saying 'make me a copy of whatever was _really_ pointed to by the
passed-in pointer'?!
would like to create a copy of the Derived object who's address was
passed in. I was hoping I could do something like this:
class Thing
{
private:
Base* ptr_;
Base* copyptr_
public:
Thing(Base* param) : ptr_(param), copyptr_(new Base(*param) {}
}
But of course this simply tries to create a new Base object which will
fail if Base has any pure virtual functions. Is there some way of
saying 'make me a copy of whatever was _really_ pointed to by the
passed-in pointer'?!