My program is supposed to make a mixed fraction. for example, the fraction 7/2 should be outputted as 3 1/2. The fraction is still not coming our correctly with my current code. Is there an error in logic in my reduce function or possibly somewhere else?
$ g++ -std=c++11 -Wall -Wextra -Wshadow foo.cpp
foo.cpp:26:9: error: expected nested-name-specifier before ‘namespace’
usingnamespace std;
^
foo.cpp: In constructor ‘Fraction::Fraction(int, int)’:
foo.cpp:41:52: warning: declaration of ‘denominator’ shadows a member of ‘Fraction’ [-Wshadow]
Fraction::Fraction(int numerator, int denominator) {
^
foo.cpp:10:7: note: shadowed declaration is here
int denominator;
^
foo.cpp:41:52: warning: declaration of ‘numerator’ shadows a member of ‘Fraction’ [-Wshadow]
Fraction::Fraction(int numerator, int denominator) {
^
foo.cpp:11:7: note: shadowed declaration is here
int numerator;
^
foo.cpp: In member function ‘void Fraction::setNum(int)’:
foo.cpp:45:38: warning: declaration of ‘numerator’ shadows a member of ‘Fraction’ [-Wshadow]
void Fraction::setNum(int numerator) {
^
foo.cpp:11:7: note: shadowed declaration is here
int numerator;
^
foo.cpp: In member function ‘void Fraction::setDen(int)’:
foo.cpp:48:40: warning: declaration of ‘denominator’ shadows a member of ‘Fraction’ [-Wshadow]
void Fraction::setDen(int denominator) {
^
foo.cpp:10:7: note: shadowed declaration is here
int denominator;
^
foo.cpp: In member function ‘void Fraction::setFraction(int, int)’:
foo.cpp:60:60: warning: declaration of ‘denominator’ shadows a member of ‘Fraction’ [-Wshadow]
void Fraction::setFraction(int numerator, int denominator) {
^
foo.cpp:10:7: note: shadowed declaration is here
int denominator;
^
foo.cpp:60:60: warning: declaration of ‘numerator’ shadows a member of ‘Fraction’ [-Wshadow]
void Fraction::setFraction(int numerator, int denominator) {
^
foo.cpp:11:7: note: shadowed declaration is here
int numerator;
^
Need to put gcd() as it isn't part of repl.it and it is part of the assignment. otherwise it doesn't compile. Also thankyou for the link but it doesn't work for me?