Skip to content

Commit 4727fd9

Browse files
committed
In C++ we can do with, Templates with multiple(different) parameters
1 parent 6735044 commit 4727fd9

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

Templates1.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
// Templates with multiple(different) parameters
5+
6+
template<class T1, class T2>
7+
class myClass{
8+
public:
9+
T1 data1;
10+
T2 data2;
11+
myClass(T1 a, T2 b){
12+
data1 = a;
13+
data2 = b;
14+
}
15+
void display(){
16+
cout << this->data1<<endl << this->data2;
17+
}
18+
};
19+
int main(){
20+
myClass<char, float> obj('X', 5.7);
21+
obj.display();
22+
return 0;
23+
}

Templates1.exe

44 KB
Binary file not shown.

0 commit comments

Comments
 (0)