テンプレートメソッドモードC++実装

579 ワード

//
//  main.cpp
//  template_pattern
//
//  Created by apple on 2019/3/12.
//  Copyright © 2019  apple. All rights reserved.
//

#include 
using namespace std;

class BaseDesigner
{
public:
    virtual void getA() = 0;
    virtual void getB() = 0;
    virtual void getC() = 0;
    void template_method() {getA(); getB(); getC();}
};

class Designer_A:public BaseDesigner
{
public:
    void getA(){}
    void getB(){cout<template_method();
    return 0;
}
getB    
getC    
Program ended with exit code: 0