#include <iostream>
using namespace std;
template <class T>
class mypair {
T a, b;
public:
mypair (T first, T second)
{a=first; b=second;}
T getmax ();
};
template <class T>
T mypair<T>::getmax ()
{
T retval;
retval = a>b? a : b;
return retval;
}
int main () {
mypair <int> myobject (100,35);
cout << myobject.getmax() << endl;
return 0;
}
c++类模板
最新推荐文章于 2024-07-20 22:49:13 发布