-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rational_Overload.h
74 lines (42 loc) · 1.67 KB
/
Rational_Overload.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//
// Keita Nonaka
//
// This is a header file for rational class
// This header is for declaring methods and variables.
//
#ifndef CS255_RATIONAL_OVERLOAD_H
#define CS255_RATIONAL_OVERLOAD_H
class Rational_Overload {
private:
int numerator; // numerator
int denominator; // denominator
int gcd (int a, int b); // gcd method
public:
Rational_Overload(); // constructor
Rational_Overload(int a, int b); // constructor
~Rational_Overload();
void add(Rational_Overload obj); // addition
void sub(Rational_Overload obj); // subtraction
void mul(Rational_Overload obj); // multiplication
void div(Rational_Overload obj); // division
Rational_Overload operator+(Rational_Overload obj); // overloading
Rational_Overload operator-(Rational_Overload obj); // overloading
Rational_Overload operator*(Rational_Overload obj); // overloading
Rational_Overload operator/(Rational_Overload obj); // overloading
Rational_Overload operator-(); // overloading
Rational_Overload operator!(); // overloading
bool operator<(Rational_Overload obj); // overloading
bool operator<=(Rational_Overload obj); // overloading
bool operator>(Rational_Overload obj); // overloading
bool operator>=(Rational_Overload obj); // overloading
bool operator==(Rational_Overload obj); // overloading
bool operator!=(Rational_Overload obj); // overloading
void reciprocal(); // reciprocal
void negate(); // negation
void reduce(int& numer, int& denom); // reduce
int getNumer();
int getDenom();
void print(); // print fraction
void printFloat(); // print float value
};
#endif //CS255_RATIONAL_OVERLOAD_H