1 #include <iostream>
2 #include <string>
3
4 using namespace std;
5
6
7 class STTarget
8 {
9 public:
10 virtual void Request()
11 {
12
13 }
14
15 virtual ~STTarget()
16 {
17
18 }
19
20 };
21
22 class STAdaptee
23 {
24 public:
25 void SpecificRequest()
26 {
27 cout<< "STAdaptee..........."<< endl;
28 }
29 };
30
31 class STAdapter: public STTarget
32 {
33 public:
34 STAdapter(STAdaptee* pstAdaptee): m_pstAdaptee(pstAdaptee)
35 {
36
37 }
38 virtual ~STAdapter()
39 {
40 delete m_pstAdaptee;
41 }
42
43 virtual void Request()
44 {
45 m_pstAdaptee->SpecificRequest();
46 }
47
48 STAdaptee* m_pstAdaptee;
49 };
50
51 int main(int argc, char* argv[])
52 {
53 STTarget* pstTarget = new STAdapter(new STAdaptee);
54
55 pstTarget->Request();
56
57 delete pstTarget;
58
59 return 0;
60 }
61 ///////////////////////////
62 [root@ ~/learn_code/design_pattern/14_adapter]$ ./adapter
63 STAdaptee...........