换句话说,给定一个基类shape
和一个派生类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);
}
我想知道我是否可以rectangle
通过调用创建一个实例:
shape *pRectangle = new shape(RECTANGLE);
以及如何实现复制构造函数,以便rectangle
通过调用获得新的:
shape *pNewRectangle = new shape(pRectangle);