forked from huangmingchuan/Cpp_Primer_Answers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exercise13_34.h
61 lines (47 loc) · 1.13 KB
/
exercise13_34.h
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
#ifndef ex13_34_h
#define ex13_34_h
#include <string>
#include <set>
class Folder;
class Message
{
friend void swap(Message &, Message &);
friend void swap(Folder &, Folder &);
friend class Folder;
public:
explicit Message(const std::string& s = "") :contents(s) {}
Message(const Message&);
Message& operator=(const Message&);
~Message();
void save(Folder&);
void remove(Folder&);
void print_debug();
private:
std::string contents;
std::set<Folder*> folders;
void add_to_Folders(const Message&);
void remove_from_Folders();
void addFldr(Folder* f) { folders.insert(f); }
void remFlddr(Folder* f) { folders.erase(f); }
};
void swap(Message&, Message&);
class Folder
{
friend void swap(Message&, Message&);
friend void swap(Folder&, Folder&);
friend class Message;
public:
Folder() = default;
Folder(const Folder&);
Folder& operator=(const Folder&);
~Folder();
void print_debug();
private:
std::set<Message*> msgs;
void add_to_Message(const Folder&);
void remove_to_Message();
void addMsg(Message* m) { msgs.insert(m); }
void remMsg(Message *m) { msgs.erase(m); }
};
void swap(Folder&, Folder&);
#endif // !ex13_34_h