diff --git a/cpp/includes/Example.hpp b/cpp/includes/Example.hpp index 84b425d..04917eb 100644 --- a/cpp/includes/Example.hpp +++ b/cpp/includes/Example.hpp @@ -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 diff --git a/cpp/src/Example.cpp b/cpp/src/Example.cpp index 13f7c03..1706b43 100644 --- a/cpp/src/Example.cpp +++ b/cpp/src/Example.cpp @@ -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; +}