need help with fraction operations assignment

I have to work on an assignment were I write a program where the user inputs a numerator and denominator value, and then the program spits out the corresponding fraction. Then the user inputs a second numerator and denominator, and then the program adds, subtracts, multiplies, and divides the second fraction by the first fraction. I am really confused on how to do this. Im not sure if I did the overload functions correctly. Im not sure where to proceed after the main() function. My teacher doesn't really do a good job of explaining this. Any help would be appreciated

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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
  # include <iostream>

using namespace std;

class fraction
{
private:
    int num, denom;
    
public:
    void set_num(int inputnum){
        cout << "Enter first numerator. " << endl;
        cin >> inputnum;
        
        inputnum = num;
    }
        
    
    
    int get_num(){
        return num;
    }
        
        
        
    
    void set_denom(int inputdenom){
        cout << "Enter first denominator. " << endl;
        cin >> inputdenom;
        
        inputdenom = denom;
    }
        
        
    
    int get_denom(){
        return denom;
    }
        
      
    
        
  
       
        
        
        
        fraction operator+(const fraction f) const{
            fraction r;
            r.num = (num * f.denom)+(denom + f.num);
            r.denom = denom*(f.denom);
            return r;
        }
        fraction operator-(const fraction f) const{
            fraction r;
            r.num = (num * f.denom)-(denom + f.num);
            r.denom = denom*(f.denom);
            return r;
        }
        fraction operator*(const fraction f) const{
            fraction r;
            r.num = num * (f.num);
            r.denom = denom * (f.denom);
            return r;
        }
        fraction operator/(const fraction f) const{
            fraction r;
            r.num = num * (f.denom);
            r.denom = denom * (f.num);
            return r;
        }
    
    fraction operator <<(const fraction f) const{
        fraction r;
        cout << r.num << "/" << r.denom << endl;
    }
        
        int main(){
            fraction  object;
            
            object.set_num();
            
         
            
            object.set_denom();
            
            
            
            
        }
            
            
        };
        
Were you given a prompt to follow?

I would suspect that you're expected to create two fraction objects and demonstrate that all the overloaded operators work. This is just a complete shot in the dark, though. >_>

-Albatross
Topic archived. No new replies allowed.