Hi everyone!
This question is related to how implement a copy constructor for a class that has a pointer to an abstract type. Here is an example:
Code:
class MyAbstract
{
public:
virtual void abstractMethod() const = 0;
};
class UseAbstract
{
public:
UseAbstract (MyAbstract *abstract, int b)
{
abstract_ = abstract;
b_ = b;
}
UseAbstract (const UseAbstract &other)
{
b_ = other.b_;
//abstract_ = new ??
}
private:
MyAbstract *abstract_;
int b_;
};
How can I implement the copy constructor for UseAbstract? I can't create an object for 'MyAbstract'.
Thanks a lot!