-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exercise code/operators, about the solution #312
Comments
I would still advice against making the unary constructor Apart from that, looking at the solution to the operators exercise, where do you think an implicit conversion from |
If you allow the implicit conversion, for each operator, on eonly need to implement the version (Fraction const &, Fraction const &), and there is no need to implement (Fraction const &, int) and (int, Fraction const &). |
Hmm. I see. That would save you 5 operators, indeed. However, it might be less efficient since you now perform extra work in |
Also, if performance is the aim, I feel that implementing >= <= > reusing > and == is not always optimal ;) To be checked, I did not dig this. And I rather prefer the spirit of the exercise the way it is currently, promoting "consistency first", which you ensure implementing >= <= > from > and ==. |
@sponce @bernhardmgruber @hageboeck I generally recommand to make any unary constructor explicitly. Yet, in this example, how dangerous is it to let the compiler transform an int into some Fraction ? If you allow this, the implementation of operators is made largely simpler.
The text was updated successfully, but these errors were encountered: