-
Notifications
You must be signed in to change notification settings - Fork 1
/
Lab_solution_13.cpp
45 lines (38 loc) · 1.1 KB
/
Lab_solution_13.cpp
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
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
template <typename T>
class MathOperation
{
public:
MathOperation(T a, T b)
{
m_a = a;
m_b = b;
}
T getA()
{
return m_a;
}
T getB()
{
return m_b;
}
private:
T m_a = 0;
T m_b = 0;
};
int main()
{
MathOperation<int> intOp(1, 3);
MathOperation<float> floatOp(1.3f, 5.6f);
MathOperation<long> longOp(5, 8);
cout << "type:" << typeid(intOp.getA()).name() << "- a=" << intOp.getA() <<
", type:" << typeid(intOp.getB()).name() << "- b= " << intOp.getB() << endl;
cout << "type:" << typeid(floatOp.getA()).name() << "- a=" << floatOp.getA() <<
", type:" << typeid(floatOp.getB()).name() << "- b= " << floatOp.getB() << endl;
cout << "type:" << typeid(longOp.getA()).name() << "- a=" << longOp.getA() <<
", type:" << typeid(longOp.getB()).name() << "- b= " << longOp.getB() << endl;
return 0;
}