35 lines
526 B
C++
35 lines
526 B
C++
class Strategy
|
|
{
|
|
public:
|
|
Strategy(){}
|
|
virtual ~Strategy(){}
|
|
virtual int doOperation(int num1, int num2) = 0;
|
|
};
|
|
|
|
class OperationAdd : public Strategy
|
|
{
|
|
public:
|
|
int doOperation(int num1, int num2)
|
|
{
|
|
return num1 + num2;
|
|
}
|
|
};
|
|
|
|
class OperationSubstract: public Strategy
|
|
{
|
|
public:
|
|
int doOperation(int num1, int num2)
|
|
{
|
|
return num1 - num2;
|
|
}
|
|
};
|
|
|
|
class OperationMultiply: public Strategy
|
|
{
|
|
public:
|
|
int doOperation(int num1, int num2)
|
|
{
|
|
return num1 * num2;
|
|
}
|
|
};
|