/*制作饮品*/
#include<string>
#include<iostream>
using namespace std;
class Base
{
public:
virtual void boil() = 0;
virtual void chongpao() = 0;
virtual void addsomething() = 0;
void makedrink()
{
boil();
chongpao();
addsomething();
}
};
/*制作咖啡*/
class coffee :public Base
{
public:
void boil()
{
cout << "煮农夫山泉" << endl;
}
void chongpao()
{
cout << "冲泡咖啡" << endl;
}
void addsomething()
{
cout << "添加糖和牛奶" << endl;
}
};
/*冲泡茶叶*/
class Tea :public Base
{
public:
void boil()
{
cout << "煮百所山" << endl;
}
void chongpao()
{
cout << "冲泡茶叶" << endl;
}
void addsomething()
{
cout << "添加枸杞和红枣" << endl;
}
};
void dowork(Base * bs)
{
bs->makedrink();
}
void test()
{
dowork(new coffee);
cout << "-------------------" << endl;
dowork(new Tea);
}
int main()
{
test();
system("pause");
return 0;
}