Template Example 3 – C++ Language

#include <iostream>

using namespace std;
template<class T, class M>
class test
{
public:
T name;
M roll;
void get()
{
cout<<“Name”<<endl;
cin>>name;
cout<<“roll”<<endl;
cin>>roll;
}
void display()
{
cout<<“Name is :”<<name<<endl;
cout<<“Roll is :”<<roll<<endl;
}
};

int main()
{
test<string, int> obj;
obj.get();
obj.display();
return 0;
}