forked from micooz/DesignPattern
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBridgePattern.cpp
More file actions
59 lines (43 loc) · 946 Bytes
/
Copy pathBridgePattern.cpp
File metadata and controls
59 lines (43 loc) · 946 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
52
53
54
55
56
57
58
59
#include <iostream>
using namespace std;
// Abstraction
class Abstraction {
public:
virtual void Operation() = 0;
virtual ~Abstraction() { }
protected:
Abstraction() { }
};
// AbstractionImp
class AbstractionImp :public Abstraction {
public:
virtual void Operation() = 0;
virtual ~AbstractionImp() { }
protected:
AbstractionImp() { }
};
class ConcreteAbstractionImp :public AbstractionImp {
public:
void Operation() {
cout << "ConcreteAbstractionImp Operation..." << endl;
}
};
class RefinedAbstraction :public Abstraction {
public:
RefinedAbstraction(AbstractionImp *imp) {
_imp = imp;
}
void Operation() {
_imp->Operation();
}
private:
AbstractionImp *_imp;
};
int main() {
AbstractionImp *imp = new ConcreteAbstractionImp();
Abstraction *abs = new RefinedAbstraction(imp);
abs->Operation();
delete imp;
delete abs;
return 0;
}