Class rational
{
Public:
Rational (INT Numerator = 1, int demominator = 1 );
Rational (const rational &);
Int getnumerator () const;
Int getdemominator () const;
Void printrational () const;
Void setnumerator (INT numberator );
Void setdemominator (INT demominator );
Const rational operator = (const rational &);
PRIVATE:
Int numerator;
Int demominator;
};
Rational: Rational (INT numerator, int demominator): numerator (numerator ),
Demominator (demominator)
{
}
Rational: Rational (const rational & RHs): numerator (RHS. getnumerator ()),
Demominator (RHS. getdemominator ())
{
}
Const rational: Operator = (const rational & RHs)
{
Return rational (RHS. getnumerator (), RHS. getdemominator ());
}
Int rational: getdemominator () const
{
Return demominator;
}
Int rational: getnumerator () const
{
Return numerator;
}
Void rational: setdemominator (INT demominator)
{
Demominator = demominator;
}
Void rational: setnumerator (INT numberator)
{
Numberator = numberator;
}
Void rational: printrational () const
{
Cout <"rational (" <getnumerator () <"," <getdemominator () <")" <Endl;
}
Const rational operator * (const rational & rhs1, const rational & rhs2)
{
Return rational (rhs1.getnumerator () * rhs2.getnumerator (),
Rhs1.getdemominator () * rhs2.getdemominator ());
}