/* template<typename T> Comparator<T>::Comparator (T x, T y) : m_x (x), m_y (y) {} template<typename T> T Comparator<T>::max (void) const { return m_x < m_y ? m_y : m_x; } template<typename T> T Comparator<T>::min (void) const { return m_x < m_y ? m_x : m_y; } */ int main (void) { Comparator<int> ci (123, 456); cout << ci.max() << ' ' << ci.min() << endl; Comparator<double> cd (1.23, 4.56); cout << cd.max() << ' ' << cd.min() << endl; Comparator<string> cs ("hello", "world"); cout << cs.max() << ' ' << cs.min() << endl; Comparator<char const*> cp("hello","world"); cout << cp.max() << ' ' << cp.min() << endl; return 0; }
int main (void) { //int x = 123, y = 456; double x = 1.23, y = 4.56; //Comparator<int> comp (x, y); Comparator<double> comp (x, y); cout << comp.max () << ' ' << comp.min () << endl; cout << ::max (x, y) << ' ' << ::min (x, y) << endl; return 0; }