better copy assignement default
This commit is contained in:
parent
f3ca4dd8fa
commit
387511e750
2 changed files with 9 additions and 3 deletions
|
@ -7,8 +7,8 @@ struct Example {
|
|||
Example(); // constructor
|
||||
virtual ~Example(); // destructor
|
||||
|
||||
Example(const Example &); // copy constructor
|
||||
Example &operator=(const Example &); // copy assignement
|
||||
Example(const Example &); // copy constructor
|
||||
const Example &operator=(const Example &); // copy assignement
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -6,4 +6,10 @@ Example::~Example() {}
|
|||
|
||||
Example::Example(const Example &) {}
|
||||
|
||||
Example &Example::operator=(const Example &src) { return *this; }
|
||||
const Example &Example::operator=(const Example &src) {
|
||||
if (this == &src) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue