-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask 4.hpp
68 lines (57 loc) · 1.63 KB
/
task 4.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
//
// Created by vadim on 24.05.22.
//
#ifndef LAB2_07_VIRTUAL_TASK_4_HPP
#define LAB2_07_VIRTUAL_TASK_4_HPP
#include "iostream"
class Abstr_vir {
public:
explicit Abstr_vir(double x = 0) : num(x){
std::cout << "abstr_vir constructor" << std::endl;
}
virtual void print() = 0;
virtual ~Abstr_vir() {
std::cout << std::endl << "Object of class \"Abstr\" was deleted" << std::endl;
}
double num;
};
class Deriv1_vir : virtual public Abstr_vir{
public:
explicit Deriv1_vir(double x = 0) : num(x){
std::cout << "deriv1_vir constructor" << std::endl;
}
void print() override{
std::cout << "Deriv1 = [" << num << ']';
}
virtual ~Deriv1_vir() {
std::cout << std::endl << "Object of class \"Deriv1\" was deleted" << std::endl;
}
double num;
};
class Deriv2_vir : virtual public Abstr_vir{
public:
explicit Deriv2_vir(double x = 0) : num(x){
std::cout << "deriv2_vir constructor" << std::endl;
}
void print() override {
std::cout << "Deriv2 = [" << num << ']';
}
virtual ~Deriv2_vir() {
std::cout << std::endl << "Object of class \"Deriv2\" was deleted" << std::endl;
}
double num;
};
class Deriv3_vir : public Deriv1_vir, public Deriv2_vir{
public:
explicit Deriv3_vir(double x = 0) : num(x){
std::cout << "deriv3_vir constructor" << std::endl;
}
void print() override {
std::cout << "Deriv3 = [" << num << ']';
}
virtual ~Deriv3_vir() {
std::cout << std::endl << "Object of class \"Deriv3\" was deleted" << std::endl;
}
double num;
};
#endif //LAB2_07_VIRTUAL_TASK_4_HPP