Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 11 / Examples / Person / Person.cpp
diff options
context:
space:
mode:
Commit4993c6468aa07e7c6a006a721fe82aaa4413eede (patch)
Author
 angeld55 <angel_dimitriev@abv.bg>
2022-05-17 20:42:42 +0300
Committer
 angeld55 <angel_dimitriev@abv.bg>
2022-05-17 20:42:42 +0300
Files819dc184dc1c4d23ff71bdd5d9d538b8ce32a5de /Sem. 11/Examples/Person/Person.cpp
Object-oriented_programming_FMI-4993c6468aa07e7c6a006a721fe82aaa4413eede.tar
Object-oriented_programming_FMI-4993c6468aa07e7c6a006a721fe82aaa4413eede.tar.gz
Object-oriented_programming_FMI-4993c6468aa07e7c6a006a721fe82aaa4413eede.zip
Parent8af74b1eeed52119ecaaf57ff6779edbc219c34b (diff)
added bar task
1 files changed, 0 insertions, 78 deletions
-rw-r--r--Sem. 11/Examples/Person/Person.cpp78
diff --git a/Sem. 11/Examples/Person/Person.cpp b/Sem. 11/Examples/Person/Person.cpp
deleted file mode 100644
index 439dc2b..0000000
--- a/Sem. 11/Examples/Person/Person.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-#pragma once
-#include "Person.h"
-#include <cstring>
-#pragma warning (disable:4996)
-
-
-
-void Person::copyFrom(const Person& other)
-{
- name = new char[strlen(other.name) + 1];
- strcpy(name, other.name);
- age = other.age;
-}
-
-void Person::free()
-{
- delete[] name;
-}
-
-Person::Person(const char* name, int age)
-{
- setName(name);
- setAge(age);
-}
-
-Person::Person(const Person& other)
-{
- copyFrom(other);
-}
-
-Person& Person::operator=(const Person& other)
-{
- if (this != &other)
- {
- free();
- copyFrom(other);
- }
- return *this;
-}
-const char* Person::getName() const
-{
- return name;
-}
-
-int Person::getAge() const
-{
- return age;
-}
-
-void Person::setName(const char* name)
-{
- if (name == nullptr || this->name == name)
- return;
-
- delete[] this->name;
- size_t nameLen = strlen(name);
- this->name = new char[nameLen + 1];
- strcpy(this->name, name);
-}
-
-void Person::setAge(int age)
-{
- if(age < 0 || age > 120)
- age = 40;
- this->age = age;
-}
-
-
-Person::~Person()
-{
- free();
-}
-
-void Person::print() const
-{
- std::cout << name << " " << age << std::endl;
-}
-