QtDesignPatterns/bridgepattern/first_interface.h

29 lines
611 B
C
Raw Permalink Normal View History

2024-02-06 17:21:37 +08:00
#include <iostream>
using namespace std;
class DrawApi
{
public:
DrawApi(){}
virtual ~DrawApi(){}
virtual void drawCircle(int radius, int x, int y) = 0;
};
class RedCircle: public DrawApi
{
public:
void drawCircle(int radius, int x, int y)
{
cout << "drawing circle [ color: red, radius: " << radius << ", x: " << x << ", y: " << y << " ]" << endl;
}
};
class GreenCircle: public DrawApi
{
public:
void drawCircle(int radius, int x, int y)
{
cout << "drawing circle [ color: green, radius: " << radius << ", x: " << x << ", y: " << y << " ]" << endl;
}
};