Задание. Реализовать класс Fraction согласно файлу fraction.h, представ-
ленному ниже:
// fraction.h
class Fraction
{
private:
int ch;
int zn;
Fraction & shorten(); // сокращение дроби
pubic:
Fraction();
Fraction(int cel, int ch, int zn);
~Fraction();
31
int get_cel();
int get_ch();
int get_zn();
Fraction & set_cel( int);
Fraction & set_chisl( int);
Fraction & set_zn( int);
Fraction sum(const Fraction &)const;
Fraction dif(const Fraction &)const;
Fraction mul(const Fraction &)const;
Fraction div(const Fraction &)const;
Fraction operator-();
Fraction operator+(const Fraction &)const;
Fraction operator-(const Fraction &)const;
Fraction operator*(const Fraction &)const;
Fraction operator/(const Fraction &)const;
Fraction operator+(int);
Fraction operator-(int);
Fraction operator*(int);
Fraction operator/(int);
Fraction operator%(int);
Fraction & operator++();
Fraction operator++(int);
Fraction & operator--();
Fraction operator--(int);
int operator>(const Fraction &);
int operator<(const Fraction &);
int operator>=(const Fraction &);
int operator<=(const Fraction &);
int operator==(const Fraction &);
void operator()();
int operator[](int);
operatordouble();
friend Fraction operator+(int, const Fraction &);
friend Fraction operator-(int, const Fraction &);
friend Fraction operator*(int, const Fraction &);
friend Fraction operator/(int, const Fraction &);
32
friend istream & operator>>(istream &, Fraction &);
friend ostream & operator<<(ostream &, const Fraction &);
};
Достарыңызбен бөлісу: |