-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path58parameterintemp.cpp
More file actions
58 lines (54 loc) · 1.05 KB
/
Copy path58parameterintemp.cpp
File metadata and controls
58 lines (54 loc) · 1.05 KB
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
#include <iostream>
#include <cstring>
#include <fstream>
using namespace std;
/*
TEMPLATE WITH MULTIPLE PARAMETERS
Syntax:
template < class T1, class T2,.....COMMA SEPERATED INFINITE CUSTOM OR GENERIC DATATYPES>
class {{name}}
{
T1 variable;
T2 variable;
body...
};
*/
template <class T1, class T2>
class DataDisplay
{
public:
T1 data1;
T2 data2;
void display()
{
cout << "Data 1 of class : " << this->data1 << endl
<< "Data 2 of class : " << this->data2 << endl;
}
};
template <class T1, class T2>
class DataDisplaying
{
public:
T1 data1;
T2 data2;
DataDisplaying(T1 a, T2 b)
{
data1 = a;
data2 = b;
}
void display()
{
cout << "Data 1 of class : " << this->data1 << endl
<< "Data 2 of class : " << this->data2 << endl;
}
};
int main()
{
DataDisplay<int, char> obj;
obj.data1 = 45;
obj.data2 = 'K';
obj.display();
DataDisplaying<char, float> objx('c', 2.87);
objx.display();
return 0;
}