I'm just wondering if someone could point out an issue that i'm having.
I have three files: main.cpp / Fraction.cpp / Fraction.h
Here is the relevant Fraction.h (class) information:
class Fraction{
//Variables
int numerator;
int denominator;
};
Inside the main.cpp, I declare some objects:
Fraction left, right, result, ref;
And then try to add them together:
result = left + right;
So then inside my Fraction.cpp file (I know its not where its supposed to be) is my operator overloading function:
Fraction& operator+(const Fraction& l, const Fraction& r){
Fraction sum;
int numSum, denSum;
numSum = l.numerator2() + r.numerator2(); // these functions get the values
denSum = l.denominator2() + r.denominator2(); // these functions get the values
sum.set(numSum, denSum);
return sum;
}
The following error occurs telling me that no function matches the expression in the main:
w6.cpp:29:20: error: invalid operands to binary expression ('Fraction' and 'Fraction')
result = left + right;
Does anyone have any ideas as to why this is occurring? Thank you!