Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 07
diff options
context:
space:
mode:
1 files changed, 2 insertions, 2 deletions
-rw-r--r--Sem. 07/Person/Person.cpp4
diff --git a/Sem. 07/Person/Person.cpp b/Sem. 07/Person/Person.cpp
index eff781d..3b241c7 100644
--- a/Sem. 07/Person/Person.cpp
+++ b/Sem. 07/Person/Person.cpp
@@ -45,9 +45,9 @@ int Person::getAge() const
void Person::setName(const char* name)
{
- if (this->name == name)
+ if (name == nullptr || this->name == name)
return;
-
+
delete[] this->name;
size_t nameLen = strlen(name);
this->name = new char[nameLen + 1];