#include // Create an ordered pair (i, j) where // (i, j) < (k, l) when i < k // // This defines a strict weak ordering: // // ... < (-1, *) < (0, *) < (1, *) < (2, *) < ... class ordered_pair; ostream &operator<<( ostream &, ordered_pair const & ); class ordered_pair { private: int i, j; public: ordered_pair( int a = 0, int b = 0 ):i(a), j(b) { // empty constructor } bool operator <( ordered_pair const &obj ) const { return i < obj.i; } bool operator ==( ordered_pair const &obj ) const { return i == obj.i; } friend ostream &operator <<( ostream &, ordered_pair const & ); }; std::ostream &operator <<( std::ostream &out, ordered_pair const &x ) { out << "(" << x.i << "," << x.j << ")"; return out; }