つまり、基本クラス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);