File tree 1 file changed +13
-9
lines changed
1 file changed +13
-9
lines changed Original file line number Diff line number Diff line change 1
1
#pragma once
2
2
3
- #include < Stream.h>
4
3
#include < IPAddress.h>
4
+ #include < Stream.h>
5
5
6
6
class Client : public Stream {
7
7
public:
@@ -11,16 +11,20 @@ class Client : public Stream {
11
11
mGodmodeDataIn = new String;
12
12
}
13
13
}
14
- Client (const Client &client) {
15
- // copy constructor
16
- if (mGodmodeDataIn ) {
17
- mGodmodeDataIn = new String (mGodmodeDataIn ->c_str ());
14
+ Client (const Client &client) { // copy constructor
15
+ if (this != &client) { // not a self-assignment
16
+ if (mGodmodeDataIn ) { // replace what we previously had
17
+ delete mGodmodeDataIn ; // get rid of previous value
18
+ mGodmodeDataIn = new String (client.mGodmodeDataIn ->c_str ());
19
+ }
18
20
}
19
21
}
20
- Client & operator =(const Client &client) {
21
- // copy assignment operator
22
- if (mGodmodeDataIn ) {
23
- mGodmodeDataIn = new String (mGodmodeDataIn ->c_str ());
22
+ Client &operator =(const Client &client) { // copy assignment operator
23
+ if (this != &client) { // not a self-assignment
24
+ if (mGodmodeDataIn ) { // replace what we previously had
25
+ delete mGodmodeDataIn ; // get rid of previous value
26
+ mGodmodeDataIn = new String (client.mGodmodeDataIn ->c_str ());
27
+ }
24
28
}
25
29
return *this ;
26
30
}
You can’t perform that action at this time.
0 commit comments