模版模式


#include 
#include 

using namespace std;

class TestPaper {
public :
    TestPaper(){};
    ~TestPaper(){};
    void TestQuestion1(){cout<<"question1"<



void testLesson7(){
    
    TestPaper * studentA = new TestPaperA();
    studentA->TestQuestion1();
    studentA->TestQuestion2();
    studentA->TestQuestion3();
    TestPaper * studentB = new TestPaperB();
    studentB->TestQuestion1();
    studentB->TestQuestion2();
    studentB->TestQuestion3();
}



重要概念

概念: 定义一个算法的基本骨架,只是微小部分不得实现推迟到子类实现,用的是继承的特性,但思想是不一样的,继承是模版模式的工具。

你可能感兴趣的:(模版模式)