Write a c++ program to illustrate templates with multiple parameters.
AIM:
Write
a c++ program to illustrate templates with multiple parameters.
THEORY:
While creating templates, it is
possible to specify more than one type. We can use more than one generic data
type in a class template. They are declared as a comma-separated list within
the template as below:
Syntax:
Syntax:
template<class T1, class T2, ...>
class classname
{
...
...
};
SOURCE
COE:
#include<iostream>
using namespace std;
template<class T1,class T2>
class data
{
public:
data(T1
a,T2 b)
{
cout<<"\n
a= "<<a<<"\n b= "<<b;
}
};
int main()
{
data<int,float>h(2,2.5f);
data<int,char>i(15,'C');
data<float,int>j(3.12f,50);
}
Labels: oop through c++ lab
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home