#include<iostream.h> template<class T> class pair { T value1,value2; public: pair(T first,T second) { value1=first; value2=second; } T getmax(); }; template<class T> T pair <T>::getmax() { T retval; retval=value1>value2?value1:value2; return retval; } int main() { pair<int>myobject(100,75); cout<<myobject.getmax(); return 0; }
时间: 2024-10-05 05:06:06