#include <iostream>
using namespace std;
class Strategy {
public:
virtual ~Strategy() {}
virtual void crypt() = 0;
};
class AES: public Strategy {
public:
virtual void crypt() {
cout << "AES crypt" << endl;
}
};
class DES: public Strategy {
public:
virtual void crypt() {
cout << "DES crypt" << endl;
}
};
class Context {
public:
void setStrategy(Strategy* strategy) {
m_strategy = strategy;
}
void operate() {
m_strategy->crypt();
}
private:
Strategy* m_strategy;
};
int main() {
Strategy* des = new DES;
des->crypt();
cout << endl;
Context* context = new Context;
context->setStrategy(des);
context->operate();
delete context;
delete des;
return 0;
}