194                                __         7. Ad hoc 

private:

long a, q;

enum {BIG = 100};

i.    .

J   /

inline int greater(int i, int j)

{ return ( i > j ? i : j) ; }
inline double greater(double x, double y)

{ return ( x >  ? x : y); }
inline rational greater(rational w, rational z)

{ return ( w > z ? w : z); }

int main()

r
"I.

int i = 10, j = 5;

float x = 7.0;

double y = 14.5;

rational w(10), z(3.5), zmax;

cout  "\ngreater("  i  ", "  j  ") = "

 greater(i, j) ;

cout  "\ngreater("  x  ", "  y  ") = "

 greater(x, y) ;

cout  "\ngreater("  i  ", " ;

z.print() ;

cout  ") = "  greater(static_cast<rational>(i), z);

zmax = greater(w, z);

cout  "\ngreater(" ;

w.print() ;

cout  " , " ;

z.print() ;

cout  ") = " ;

zmax.print() ;

}

    :

greater(10, 5) = 10
greater(7, 14.5) = 14.5
greaterflO, 350 / 100) = 10
greater(10 / 1, 350 / 100) =10/1

      ,  .

  rational

 rational(double r) : q(BIG), a(r * BIG)()
   double  rational.