-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHuman.h
More file actions
45 lines (33 loc) · 880 Bytes
/
Human.h
File metadata and controls
45 lines (33 loc) · 880 Bytes
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
//
// Created by maxim on 17.04.2020.
//
#ifndef COURSE_WORK_HUMAN_H
#define COURSE_WORK_HUMAN_H
#include <iostream>
using cr_str = const std::string &;
class Human {
public:
// Constructor
explicit Human(cr_str f_name){
if(f_name.empty()) {
throw std::invalid_argument("Name is empty\n");
}
_name = f_name;
}
// operators for comparison objects
bool operator ==(const Human &other) const{
return _is_equals(other);
}
bool operator !=(const Human &other) const{
return !_is_equals(other);
}
// Method which return human's name
[[nodiscard]] virtual std::string get_name() const {
return _name;
}
protected:
std::string _name;
// Method for comparison
[[nodiscard]] virtual bool _is_equals(const Human &other) const = 0;
};
#endif //COURSE_WORK_HUMAN_H