In other words, given a base class shape
and a derived class rectangle
:
class shape
{
public:
enum shapeType {LINE, RECTANGLE};
shape(shapeType type);
shape(const shape &shp);
}
class rectangle : public shape
{
public:
rectangle();
rectangle(const rectangle &rec);
}
I'd like to know if I could create an instance of rectangle
by calling:
shape *pRectangle = new shape(RECTANGLE);
and how could I implement the copy constructor, in order to get a new rectangle
by calling:
shape *pNewRectangle = new shape(pRectangle);