作业帮 > 综合 > 作业

定义一个分数类fraction,重载运算符+,-,x,使之能用于分数的加减乘,编写程序,实现两个分数的和差积

来源:学生作业帮 编辑:灵鹊做题网作业帮 分类:综合作业 时间:2024/05/01 09:54:38
定义一个分数类fraction,重载运算符+,-,x,使之能用于分数的加减乘,编写程序,实现两个分数的和差积
应用c++知识回答、
定义一个分数类fraction,重载运算符+,-,x,使之能用于分数的加减乘,编写程序,实现两个分数的和差积
#ifndef FRACTION_H_
#define FRACTION_H_
#include
int gcd(int m1,int m2);
class Fraction
{
public:
\x05Fraction() {}
\x05Fraction(int f1,int f2=1);
\x05friend Fraction operator+(const Fraction &f1,const Fraction &f2);
\x05friend Fraction operator-(const Fraction &f1,const Fraction &f2);
\x05friend std::ostream& operato