-
Notifications
You must be signed in to change notification settings - Fork 0
/
Person.h
55 lines (44 loc) · 778 Bytes
/
Person.h
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
#include<string>
#include<vector>
#include "animal.h"
class Person{
private:
int age;
std::string name;
std::vector<Animal*> pets;
public:
Person(std::string name_,int age_ ,Animal* anim){
pets.push_back(anim);
name = name_;
age = age_;
}
void PrintOwner(){
std::cout<<name<<" "<<age;
}
std::string GetOwnerName() const{
return name;
}
int GetOwnerAge() const{
return age;
}
void SetAge(int a){
age = a;
}
void PrintAllAnim(){
for(auto& anim: pets){
anim->Print();
}
}
void Push_Animal(Animal* anim){
pets.push_back(anim);
}
};
std::ostream &operator<<(std::ostream &ostream, Person &p)
{
std::string name_ = p.GetOwnerName();
int age_ = p.GetOwnerAge();
ostream << name_ << " " << age_;
p.PrintAllAnim();
ostream << "\n";
return ostream;
}