📄 fraction.h
字号:
#ifndef FRACTION_H
#define FRACTION_H
#include <iostream>
using namespace std;
int count(int a); //cout the digit numbers of an integer
class fraction
{
friend ostream &operator<<( ostream &, const fraction &);
friend istream &operator>>( istream &, fraction &);
friend fraction operator+(const fraction &, const fraction &);
friend fraction operator-(const fraction &, const fraction &);
friend fraction operator*(const fraction &, const fraction &);
friend fraction operator/(const fraction &,fraction &);
friend bool operator>(const fraction &, const fraction &);
friend bool operator>=(const fraction &, const fraction & );
friend bool operator<(const fraction &, const fraction &);
friend bool operator<=(const fraction &, const fraction &);
friend bool operator==(const fraction &, const fraction &);
friend bool operator!=(const fraction &, const fraction &);
public:
fraction(int,int); //defacult constructor
~fraction(); //destructor
void simplify();
void reciprocal(); //function to get the reciprocal
void set_denominator(int);
void set_numerator(int);
void set_fraction(int,int);
int get_numerator();
int get_denominator();
int digit_number();
protected:
int denominator;
int numerator;
}
;
class Integer : public fraction
{
friend ostream &operator<<( ostream &, const Integer &);
friend int operator+( Integer &, Integer &);
friend int operator-( Integer &, Integer &);
friend int operator*( Integer &, Integer &);
friend fraction operator/(const Integer &, Integer &);
public:
Integer(int);
int digit_number();
}
;
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -