ウィキペディア:戦略パターン (C++)を参照してください。
class Context
{
private:
StrategyInterface * strategy_;
public:
explicit Context(StrategyInterface *strategy):strategy_(strategy)
{
}
void set_strategy(StrategyInterface *strategy)
{
strategy_ = strategy;
}
void execute() const
{
strategy_->execute();
}
};
Context のコンストラクターに明示的に使用することをお勧めするのはなぜですか?
ありがとうございました