QtDesignPatterns/factorypattern/interface.h

53 lines
718 B
C
Raw Permalink Normal View History

2024-02-06 17:21:37 +08:00
#include <iostream>
using namespace std;
class Shape
{
public:
Shape()
{
cout << "create Shape" << endl;
}
virtual ~Shape(){}
virtual void draw() = 0;
};
class Circle : public Shape
{
public:
Circle()
{
cout << "create Circle" << endl;
}
void draw()
{
cout << "draw Circle" << endl;
}
};
class Square: public Shape
{
public:
Square()
{
cout << "create Square" << endl;
}
void draw()
{
cout << "draw Square" << endl;
}
};
class Rectangle: public Shape
{
public:
Rectangle()
{
cout << "create Rectangle" << endl;
}
void draw()
{
cout << "draw Rectangle" << endl;
}
};