diff --git a/exercises/operators/operators.cpp b/exercises/operators/operators.cpp index af4deb09..163da43e 100644 --- a/exercises/operators/operators.cpp +++ b/exercises/operators/operators.cpp @@ -13,7 +13,7 @@ class Fraction { m_denom /= gcd; } - int m_num, m_denom; + unsigned int m_num, m_denom; }; // TODO: operators @@ -55,7 +55,7 @@ int main() { printAndCheck("One third times two", f, Fraction{2, 3}); f *= athird; - printAndCheck("One third times one third", f, Fraction{2, 9}); + printAndCheck("Two third times one third", f, Fraction{2, 9}); // you might have some redundancy between the implementation of operator* and // operator*=. Can you refactor your code and implement operator* in terms of diff --git a/exercises/operators/solution/operators.sol.cpp b/exercises/operators/solution/operators.sol.cpp index eced479d..b8abd10e 100644 --- a/exercises/operators/solution/operators.sol.cpp +++ b/exercises/operators/solution/operators.sol.cpp @@ -46,12 +46,12 @@ class Fraction { private: void normalize() { - const int gcd = std::gcd(m_num, m_denom); + auto const gcd = std::gcd(m_num, m_denom); m_num /= gcd; m_denom /= gcd; } - int m_num, m_denom; + unsigned int m_num, m_denom; }; void printAndCheck(std::string const & what, Fraction const & result, Fraction const & expected) { @@ -90,7 +90,7 @@ int main() { printAndCheck("One third times two", f, Fraction{2, 3}); f *= athird; - printAndCheck("One third times one third", f, Fraction{2, 9}); + printAndCheck("Two third times one third", f, Fraction{2, 9}); // you might have some redundancy between the implementation of operator* and // operator*=. Can you refactor your code and implement operator* in terms of