Skip to content

Commit 47be812

Browse files
committed
enable division
1 parent a6a52a5 commit 47be812

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

main.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@ using namespace std;
88
Rational r2(2, 11), r3(1, -3), r5(18, 6);
99
Rational res1 = 3 + r2 + r3;
1010
Rational res2 = (3 + r2) * r3;
11-
Rational test = r5-r3;
1211
Rational res3 = 3 + r3 * (r2 + 2) / (r5 - r3);
13-
cout <<res3<<endl;
1412

15-
// cout << 3 << " + " << r2 << " * " << r3 << " = " << res1 << endl;
16-
// cout << "(" << 3 << " + " << r2 << ")" << " * " << r3 << " = " << res2 << endl;
17-
// cout << 3 << " + " << r3 << " * " << "(" << r2 << " + " << 2 << ")" << "/"
18-
// << "(" << r5 << " - " << r3 << ")" << " = " << res3 << endl;
13+
cout << 3 << " + " << r2 << " * " << r3 << " = " << res1 << endl;
14+
cout << "(" << 3 << " + " << r2 << ")" << " * " << r3 << " = " << res2 << endl;
15+
cout << 3 << " + " << r3 << " * " << "(" << r2 << " + " << 2 << ")" << "/"
16+
<< "(" << r5 << " - " << r3 << ")" << " = " << res3 << endl;
1917

2018
return 0;
2119
}

rational.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ class Rational
3232
Rational operator+() const;
3333
Rational operator-() const;
3434

35-
// bool operator==(const Rational& other) const;
36-
// bool operator>=(const Rational& other) const;
37-
// bool operator<=(const Rational& other) const;
38-
// bool operator>(const Rational& other) const;
39-
// bool operator<(const Rational& other) const;
35+
bool operator==(const Rational& other) const;
36+
bool operator>=(const Rational& other) const;
37+
bool operator<=(const Rational& other) const;
38+
bool operator>(const Rational& other) const;
39+
bool operator<(const Rational& other) const;
4040

4141
public:
4242
int numer;

0 commit comments

Comments
 (0)