QtDesignPatterns/strategypattern/context.h

15 lines
246 B
C
Raw Normal View History

2024-02-06 17:21:37 +08:00
#include "interface.h"
class Context
{
public:
Context(Strategy *strategy) : strategy(strategy){}
int executeStrategy(int num1, int num2)
{
return strategy->doOperation(num1, num2);
}
private:
Strategy *strategy;
};