- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFactoryPattern.h
More file actions
Latest commit
30 lines (27 loc) · 598 Bytes
/
Copy pathFactoryPattern.h
File metadata and controls
30 lines (27 loc) · 598 Bytes
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
#ifndef FACTORYPATTERN_H_INCLUDED
#defineFACTORYPATTERN_H_INCLUDED
#include<iostream>
#include<cstring>
//A demo of Factory Design Pattern
classShape {
protected:
public:
virtualvoidDraw() = 0;
static Shape *CreateFactoryObject(std::string type);
};
classCircle : publicShape {
protected:
public:
voidDraw() {std::cout<<"Circle\n";}
};
classSquare : publicShape {
protected:
public:
voidDraw() {std::cout<<"Square\n";}
};
classAbstractFactoryObjectCreator {
protected:
public:
Shape *CreateFactoryObject(std::string type);
};
#endif// FACTORYPATTERN_H_INCLUDED