#include <iostream>
using namespace std;
template <class MYTYPE> class MyClass{
MYTYPE p1;
MYTYPE p2;
public:
MyClass(MYTYPE x, MYTYPE y){
p1 = x;
p2 = y;
}
void whatYouGot(){
cout << "i got p1 = " << p1 <<" and p2 = "<< p2 <<endl;
}
};
int main()
{
MyClass<int> intObject(22,55);
MyClass <string> stringObj("anil","anjali");
intObject.whatYouGot();
stringObj.whatYouGot();
return 0;
}
沒有留言:
張貼留言