fork download
  1. Fraction Fraction::operator-(Fraction f2)
  2. {
  3. Fraction result;
  4. result.numerator = ((numerator * f2.denominator) - (f2.numerator * denominator)) ;
  5. result.denominator = (denominator * f2.denominator);
  6. for(int i = result.numerator * result.denominator; i > 1; i--)
  7. {
  8. if ((result.numerator % i == 0) && (result.denominator % i == 0))
  9. {
  10. result.numerator = result.numerator / i;
  11. result.denominator = result.denominator / i;
  12. }
  13. }
  14. return result;
  15. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:1: error: unknown type name 'Fraction'
Fraction Fraction::operator-(Fraction f2)
^
prog.cpp:1:10: error: use of undeclared identifier 'Fraction'
Fraction Fraction::operator-(Fraction f2)
         ^
prog.cpp:1:30: error: unknown type name 'Fraction'
Fraction Fraction::operator-(Fraction f2)
                             ^
3 errors generated.
stdout
Standard output is empty