#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
//抽象模板
class DrinkTemplate {
public:
virtual void BoilWater() = 0;
virtual void Brew() = 0;
virtual void PourInCup() = 0;
virtual void AddSomething() = 0;
//模板方法
void Make() {
this->BoilWater();
this->Brew();
this->PourInCup();
this->AddSomething();
}
};
class DrinkTea:public DrinkTemplate {
public:
virtual void BoilWater() {
cout<<"煮开水"<<endl;
}
virtual void Brew() {
cout<<"抽泡茶叶"<<endl;
}
virtual void PourInCup() {
cout<<"茶叶倒入到杯中"<<endl;
}
virtual void AddSomething() {
cout<<"加入柠檬"<<endl;
}
};
void test10()
{
DrinkTea* tea = new DrinkTea;
tea->Make();
}
int main()
{
test10();
system("pause");
return 0;
}