-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHuman.cpp
More file actions
88 lines (72 loc) · 1.39 KB
/
Human.cpp
File metadata and controls
88 lines (72 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include "Human.h"
#include <iostream>
int Human::ID = 0; //Объявление статической переменной
Human::Human()
{
age = 0;
name = "No Name";
ID++;
humanID = ID;
}
Human::Human(int age, std::string name)
{
this->age = age;
this->name = name;
ID++;
this->humanID = ID;
std::cout << this << std::endl;
}
Human::Human(std::string name)
{
this->name = name;
this->age = 0;
}
Human::Human(std::string name, int age)
{
this->age = age; //Name берётся из констуктора Human(name);
}
Human::~Human()
{
std::cout << "Destructor" << this << std::endl;
}
Human::Human(const Human& other)
{
this->name = other.name;
this->age = other.age;
std::cout << "Copy Constructor" << this << std::endl;
}
Human& Human::operator=(const Human& other)
{
this->name = other.name;
this->age = other.age;
std::cout << "Operator =" << this << std::endl;
return *this;
}
void Human::PrintInfo()
{
std::cout << "Name: " << name << "\tAge: " << age << std::endl;
}
void Human::SetAge(int valueAge)
{
age = valueAge;
}
void Human::SetName(std::string name)
{
this->name = name;
}
std::string Human::GetName()
{
return name;
}
int Human::GetAge()
{
return age;
}
int Human::GetID()
{
return humanID;
}
//void Human::TakeApple(Apple& apple)
//{
// std::cout << "Take Apple " << std::endl << "Weight: " << apple.weight << "\tColor: " << apple.color << std::endl;
//}