-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplatemethod.h
39 lines (32 loc) · 1.2 KB
/
templatemethod.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef TEMPLATEMETHOD_H
#define TEMPLATEMETHOD_H
#include "templatemethod/italianhoagie.h"
#include "templatemethod/veggiehoagie.h"
#include <iostream>
#include <memory>
/*!
* What is the Template Method Design Pattern
*
* Used to create a group of subclasses that have to execute a similar
* group of methods
*
* You create an abstract class that contains a method called the Template Method
*
* The Template Method contains a series of method calls that every subclass
* object will call
*
* The subclass objects can override some of the method calls
*/
void templateMethodPattern()
{
std::cout << "============================================================" << std::endl;
std::cout << "===================Template Method Pattern==================" << std::endl;
auto cust12Hoagie = std::make_unique<ItalianHoagie>();
cust12Hoagie->makeSandwich();
std::cout << std::endl;
auto cust13Hoagie = std::make_unique<VeggieHoagie>();
cust13Hoagie->makeSandwich();
std::cout << "===================Template Method Pattern==================" << std::endl;
std::cout << "============================================================" << std::endl;
}
#endif // TEMPLATEMETHOD_H