-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask2.hpp
112 lines (96 loc) · 2.71 KB
/
task2.hpp
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#ifndef LAB2_07_VIRTUAL_TASK2_HPP
#define LAB2_07_VIRTUAL_TASK2_HPP
#include "iostream"
class Abstr {
double num;
public:
explicit Abstr(double x = 0) : num(x){}
virtual void print() = 0;
virtual ~Abstr() {
std::cout << std::endl << "Object of class \"Abstr\" was deleted" << std::endl;
}
};
class Deriv1 : public Abstr{
double num;
public:
explicit Deriv1(double x = 0) : num(x){}
void print() override{
std::cout << "Deriv1 = [" << num << ']';
}
virtual ~Deriv1() {
std::cout << std::endl << "Object of class \"Deriv1\" was deleted" << std::endl;
}
};
class Deriv2 : public Deriv1{
double num;
public:
explicit Deriv2(double x = 0) : num(x){}
void print() override {
std::cout << "Deriv2 = [" << num << ']';
}
virtual ~Deriv2() {
std::cout << std::endl << "Object of class \"Deriv2\" was deleted" << std::endl;
}
};
class Deriv3 : public Deriv1{
double num;
public:
explicit Deriv3(double x = 0) : num(x){}
void print() override {
std::cout << "Deriv3 = [" << num << ']';
}
virtual ~Deriv3() {
std::cout << std::endl << "Object of class \"Deriv3\" was deleted" << std::endl;
}
};
class Abstr_vir1 {
public:
double num;
explicit Abstr_vir1(double x = 0) : num(x){
std::cout << "abstr_vir constructor" << std::endl;
}
virtual void print() = 0;
virtual ~Abstr_vir1() {
std::cout << std::endl << "Object of class \"Abstr\" was deleted" << std::endl;
}
};
class Deriv1_vir1 : public Abstr_vir1{
public:
double num;
explicit Deriv1_vir1(double x = 0) : num(x){
std::cout << "deriv1_vir constructor" << std::endl;
}
void print() override{
std::cout << "Deriv1 = [" << num << ']';
}
virtual ~Deriv1_vir1() {
std::cout << std::endl << "Object of class \"Deriv1\" was deleted" << std::endl;
}
};
class Deriv2_vir1 : public Abstr_vir1{
public:
double num;
explicit Deriv2_vir1(double x = 0) : num(x){
std::cout << "deriv2_vir constructor" << std::endl;
}
void print() override {
std::cout << "Deriv2 = [" << num << ']';
}
virtual ~Deriv2_vir1() {
std::cout << std::endl << "Object of class \"Deriv2\" was deleted" << std::endl;
}
};
class Deriv3_vir1 : public Deriv1_vir1, public Deriv2_vir1{
public:
double num;
explicit Deriv3_vir1(double x = 0) : num(x){
std::cout << "deriv3_vir constructor" << std::endl;
}
void print() override {
std::cout << "Deriv3 = [" << num << ']';
}
virtual ~Deriv3_vir1() {
std::cout << std::endl << "Object of class \"Deriv3\" was deleted" << std::endl;
}
};
#endif //LAB2_07_VIRTUAL_TASK2_HPP