1. #include <iostream>
    2. using namespace std;
    3. class makeDrink{
    4. public:
    5. virtual void step1() = 0;
    6. virtual void step2() = 0;
    7. virtual void step3() = 0;
    8. virtual void step4() = 0;
    9. void make(){
    10. step1();
    11. step2();
    12. step3();
    13. step4();
    14. }
    15. };
    16. class makeCoffee: public makeDrink{
    17. public:
    18. void step1(){
    19. cout << "boil water" << endl;
    20. }
    21. void step2(){
    22. cout << "put in couple" << endl;
    23. }
    24. void step3(){
    25. cout << "boil coffee" << endl;
    26. }
    27. void step4(){
    28. cout << "put some milk" << endl;
    29. }
    30. };
    31. class makeTea: public makeDrink{
    32. public:
    33. void step1(){
    34. cout << "boil water" << endl;
    35. }
    36. void step2(){
    37. cout << "put in couple" << endl;
    38. }
    39. void step3(){
    40. cout << "boil tea" << endl;
    41. }
    42. void step4(){
    43. cout << "put something" << endl;
    44. }
    45. };
    46. void doWork(makeDrink& domake){
    47. domake.make();
    48. }
    49. int main(){
    50. makeTea tea;
    51. makeCoffee coffee;
    52. doWork(tea);
    53. doWork(coffee);
    54. system("pause");
    55. return 0;
    56. }