任何人都可以解释这个错误,为什么我得到它?我相信我已经在我的单独课程中完成了所有的算术运算.
该程序存储和操作分数,同时测试重载.
先感谢您.
我试图在驱动程序中测试这个,输出看起来像这样.
f1 = 3/6, f2 = 4/5
f1 + f2 = 39/30 = 13/10 = 1.3
f1 - f2 = -9/30 = -3/10 = -0.3
f1 * f2 = 12/30 = 2/5 = 0.4
f1 / f2 = 15/24 = 5/8 = 0.625
Enter a fraction [numerator denominator]: 2 5
You entered 2/5
Run Code Online (Sandbox Code Playgroud)
我的Fraction.cpp类
#include "Fraction.h"
#include <iostream>
using namespace std;
Fraction::Fraction(const int numerator, const int denominator) { }
int Fraction::getNumerator() const {
return numerator;
}
int …Run Code Online (Sandbox Code Playgroud)