You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: assign5/README.md
+8-5Lines changed: 8 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -74,11 +74,11 @@ With the help of your `operator<<`, your coworkers have been able to make good p
74
74
75
75
To be specific, you will need to:
76
76
77
-
1. Implement a destructor for the `User` class. To do so, implement the `User::~User()` SMF.
78
-
2. Make the `User` class copy constructible. To do so, implement the `User::User(const User& user)` SMF.
79
-
3. Make the `User` class copy assignable. To do so, implement the `User&User::operator=(const User& user)` SMF.
80
-
4. Prevent the `User` class from being move constructed. To do so, delete the `User::User(User&& user)` SMF.
81
-
5. Prevent the `User` class from being move assigned. To do so, delete the `User&User::operator=(User&& user)` SMF.
77
+
1. Implement a destructor for the `User` class. To do so, implement the `~User()` SMF.
78
+
2. Make the `User` class copy constructible. To do so, implement the `User(const User& user)` SMF.
79
+
3. Make the `User` class copy assignable. To do so, implement the `User& operator=(const User& user)` SMF.
80
+
4. Prevent the `User` class from being move constructed. To do so, delete the `User(User&& user)` SMF.
81
+
5. Prevent the `User` class from being move assigned. To do so, delete the `User& operator=(User&& user)` SMF.
82
82
83
83
In performing these tasks, you are expected to make changes to **both** the `user.h` and `user.cpp` files.
84
84
@@ -109,6 +109,8 @@ std::cout << charlie << std::endl;
109
109
// User(name=Charlie, friends=[Alice])
110
110
```
111
111
112
+
The functionsignaturefor this operator should be `User& operator+=(const User& rhs)`. Note that like the copy-assignment operator, it returns a reference to itself.
113
+
112
114
### `operator<`
113
115
114
116
Recall that the `<` operator is required to store users in a `std::set`, as `std::set` is implemented in terms of the comparison operator. Implement `operator<` to compare users alphabetically by name. For example:
@@ -126,6 +128,7 @@ else
126
128
// Alice is less than Charlie
127
129
```
128
130
131
+
The functionsignaturefor this operator should be `bool operator<(const User& rhs)`.
0 commit comments