forked from aaronbloomfield/pdr
-
Notifications
You must be signed in to change notification settings - Fork 228
/
Copy pathRational.h
45 lines (31 loc) · 959 Bytes
/
Rational.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// File Rational.h
#ifndef RATIONAL_H
#define RATIONAL_H
class Rational {
public:
// default constructor
Rational();
// destructor
~Rational();
// create and initialize a new Rational object
Rational(int numerator, int denominator);
// print string representation of (this) to cout
void print() const;
// return (this * b)
Rational times(Rational b) const;
// return (this + b)
Rational plus(Rational b) const;
// return (1 / this)
Rational reciprocal() const;
// return (this / b)
Rational divides(Rational b) const;
private:
int num; // the numerator
int den; // the denominator
/*************************************************************************
* Helper functions
*************************************************************************/
// return gcd(m, n)
int gcd(int m, int n);
};
#endif