-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfractionClass.h
60 lines (55 loc) · 1.73 KB
/
fractionClass.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
/*
* fractionClass.h
*
* Author: Harry Lewis
* Definition for a Fraction Class using overloaded operators for CMPE320 assignment 2.
*/
// dependencies
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
// current namespace
using namespace std;
// Fraction Class definition
class Fraction {
int numer;
int denom;
public:
Fraction();
Fraction(int);
Fraction(int, int);
// getters
int numerator() const { return numer; }
int denominator() const { return denom; }
// modifiers
int greatestCommonFactor(int, int);
// overloaded binary operators
Fraction operator - (void) const;
Fraction operator ++ ();
Fraction operator ++ (int);
Fraction operator += (const Fraction&);
bool operator <= (const Fraction&);
bool operator == (const Fraction&);
bool operator >= (const Fraction&);
friend bool operator > (const Fraction&, const Fraction&);
friend bool operator < (const Fraction&, const Fraction&);
friend Fraction operator + (const Fraction&, const Fraction&);
friend Fraction operator - (const Fraction&, const Fraction&);
friend Fraction operator * (const Fraction&, const Fraction&);
friend Fraction operator / (const Fraction&, const Fraction&);
friend bool operator != (const Fraction&, const Fraction&);
friend istream& operator >> (istream&, Fraction&);
friend ostream& operator << (ostream&, const Fraction&);
};
// Fraction Exception Class definition
class FractionException {
public:
// init exception with an error message
FractionException(const string& message);
// display the error message
string& what(void);
private:
// error message stored in 'message'
string message;
};