208                                             7. Ad hoc 

   (   ,      ), 
      .     

rational.

  rational.

class rational{

public:

friend ostream& operator(ostream& out, rational x) ;

friend istream& operator(istream& in, rational& x) ;

private:

long a, q;

};

ostream& operator(ostream& out, rational x)

/
i.

return (out  x.a  " / "  x.q  '\t');

}

         :

istream& operator(istream& , _& x)

       x,    -
   .       -, 
    .     rat ional  -
  friend        :

istream& operator(istream& in, rational& x)
{

return (in  x.a  x.q) ;

}

7.10.   ()  

 ,     ,
          -
.     ,     
 .

   ()    -.
      .     -
  (.   12, . 222  14, . 223)    ,
    (.  8,  . 228,   
).

  matrix3.cpp

//   
class matrix {