forked from ldebug/interview
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathconcrete_factory.h
More file actions
51 lines (43 loc) · 794 Bytes
/
concrete_factory.h
File metadata and controls
51 lines (43 loc) · 794 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// Created by xiemenghui on 2018/7/20.
//
#ifndef DESIGNPATTERN_CONCRETE_FACTORY_H
#define DESIGNPATTERN_CONCRETE_FACTORY_H
#include "Factory.h"
#include "concrete_product.h"
// 奔驰工厂
class BenzFactory : public Factory
{
public:
ICar* CreateCar()
{
return new BenzCar();
}
IBike* CreateBike()
{
return new BenzBike();
}
};
// 宝马工厂
class BmwFactory : public Factory
{
public:
ICar* CreateCar() {
return new BmwCar();
}
IBike* CreateBike() {
return new BmwBike();
}
};
// 奥迪工厂
class AudiFactory : public Factory
{
public:
ICar* CreateCar() {
return new AudiCar();
}
IBike* CreateBike() {
return new AudiBike();
}
};
#endif //DESIGNPATTERN_CONCRETE_FACTORY_H