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 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());
}