better copy assignement default

This commit is contained in:
Mylloon 2023-10-10 19:04:43 +02:00
parent f3ca4dd8fa
commit 387511e750
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 9 additions and 3 deletions

View file

@ -7,8 +7,8 @@ struct Example {
Example(); // constructor Example(); // constructor
virtual ~Example(); // destructor virtual ~Example(); // destructor
Example(const Example &); // copy constructor Example(const Example &); // copy constructor
Example &operator=(const Example &); // copy assignement const Example &operator=(const Example &); // copy assignement
}; };
#endif #endif

View file

@ -6,4 +6,10 @@ Example::~Example() {}
Example::Example(const 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;
}