作者:成语大世界日期:
返回目录:成语故事
class Shape
{
public:
Shape();
virtual ~Shape();
virtual void draw() = 0;
virtual void resize() = 0;
private:
};
Shape::Shape()
{
}
Shape::~Shape()
{
}
class Point : public Shape
{
public:
Point();
virtual ~Point();
virtual void draw();
virtual void resize();
private:
};
Point::Point()
{
}
Point::~Point()
{
}
void Point::draw()
{
std::cout << "i draw one point" << std::endl;
}
void Point::resize()
{
std::cout << "resize point size" << std::endl;
}
class Line : public Shape
{
public:
Line();
virtual ~Line();
virtual void draw();
virtual void resize();
private:
};
Line::Line()
{
}
Line::~Line()
{
}
void Line::draw()
{
std::cout << "i draw one line" << std::endl;
}
void Line::resize()
{
std::cout << "i resize line size" << std::endl;
}
int _tmain(int argc, _TCHAR* argv[])
{
Shape* lpPoint = new Point;
lpPoint->draw();
lpPoint->resize();
delete lpPoint;
lpPoint = NULL;
Shape* lpLine = new Line;
lpLine->draw();
lpLine->resize();
delete lpLine;
lpLine = NULL;
// add other shapes here
//Shape* lpCricle = new Circle;
return 0;
}
还有其他的几个形状,按照e68a847a686964616f333point和line来加就行了