I am starting a new assignment on operator overloading. After performing a simple addition I get an error saying, " error C2679: binary '<<': no operator found which takes a right-hand operand of type 'cs_Fraction::Fraction' (or there is no acceptable conversion). Can someone please point out what the problem is?
The error is in the insertion operator with the cout statement in main.
Thank you for pointing that out. I tried creating a fix for that and now I am getting this error.
error C2248: 'Fraction::numerator': cannot access private member declared in class 'Fraction'
You either have to declare it as a friend (like you did for operator+) or provide another way to access the numerator and denominator from outside the class.
Okay sorry, there is something going on with another with another function I started working on. I commented that out and now the cout << is working. Thank you.
Something is not making sense with a logic error though. I know the constructor initializes a fraction to 0/1 fine but when I send the argument (1,2) in a fraction object I cout it (no addition called) I get 12 and not not 1/2 like I'm expecting.
Well, the way you have the defined the << operator the numerator and denominator will be outputted right next to each other without anything in between.