41 lines
621 B
C++
41 lines
621 B
C++
#include <string>
|
|
#include <iostream>
|
|
using namespace std;
|
|
|
|
class Shape
|
|
{
|
|
public:
|
|
Shape()
|
|
{
|
|
cout << "create Shape" << endl;
|
|
}
|
|
virtual ~Shape(){}
|
|
virtual Shape *clone() = 0;
|
|
virtual void test() = 0;
|
|
};
|
|
|
|
class Circle: public Shape
|
|
{
|
|
public:
|
|
Circle(string type) : type(type)
|
|
{
|
|
cout << "create Circle" << endl;
|
|
}
|
|
~Circle(){}
|
|
Circle(const Circle& circle)
|
|
{
|
|
this->type = circle.type;
|
|
}
|
|
Shape *clone()
|
|
{
|
|
return new Circle(*this);
|
|
}
|
|
void test()
|
|
{
|
|
cout << "type: " << type << endl;
|
|
}
|
|
|
|
private:
|
|
string type;
|
|
};
|