#include <iostream>
using namespace std;
template <class Type1, class Type2> class MyClass{
Type1 p1;
Type2 p2;
int counter;
public:
MyClass(Type1 x, Type2 y){
p1 = x;
p2 = y;
counter = 100;
}
void whatYouGot(){
cout << "i got p1 = "<<p1<<" and p2 = "<<p2<<" and counter is "<<counter<<endl;
}
};
int main()
{
MyClass <int,string> ob1(24,"anil");
MyClass <float,float> ob2(22.36,66.241);
ob1.whatYouGot();
ob2.whatYouGot();
return 0;
}
沒有留言:
張貼留言