-
Notifications
You must be signed in to change notification settings - Fork 0
/
composite.cpp
72 lines (63 loc) · 1.25 KB
/
composite.cpp
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
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <iostream>
#include <vector>
using namespace std;
class PageObject {
public:
virtual void Add(PageObject a)
{
}
virtual void Remove()
{
}
virtual void Delete(PageObject a)
{
}
};
class Page : public PageObject {
public:
void Add(PageObject a)
{
cout << "something is added to the page" << endl;
}
void Remove()
{
cout << "soemthing is removed from the page" << endl;
}
void Delete(PageObject a)
{
cout << "soemthing is deleted from page " << endl;
}
};
class Copy : public PageObject {
vector<PageObject> copyPages;
public:
void AddElement(PageObject a)
{
copyPages.push_back(a);
}
void Add(PageObject a)
{
cout << "something is added to the copy" << endl;
}
void Remove()
{
cout << "something is removed from the copy" << endl;
}
void Delete(PageObject a)
{
cout << "something is deleted from the copy";
}
};
int main()
{
Page a;
Page b;
Copy allcopy;
allcopy.AddElement(a);
allcopy.AddElement(b);
allcopy.Add(a);
a.Add(b);
allcopy.Remove();
b.Remove();
return 0;
}