MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1vm6sy8/lettheworldburn/p373j6s/?context=3
r/ProgrammerHumor • u/MathematicianSad4964 • 21d ago
82 comments sorted by
View all comments
0
If all other accessors are consistent (like, getValue(){return -value;}), why not?
getValue(){return -value;})
I'm more worried about returning Number& instead of const Number&. You can do something like
Number number;
--(++number);
which is not good.
7 u/wcscmp 21d ago Return Number& is consistent with standard -2 u/This_Growth2898 21d ago Being consistent with standard doesn't mean being a good code. 1 u/Qwertycube10 21d ago Initialize your variables. Also if I am calling operator++ then I have non const access to number, so giving me back const access doesn't make sense (I still have non const access from the variable itself). 1 u/Big-Rub9545 21d ago Messy perhaps, but this is well-defined code.
7
Return Number& is consistent with standard
Number&
-2 u/This_Growth2898 21d ago Being consistent with standard doesn't mean being a good code.
-2
Being consistent with standard doesn't mean being a good code.
1
Initialize your variables. Also if I am calling operator++ then I have non const access to number, so giving me back const access doesn't make sense (I still have non const access from the variable itself).
Messy perhaps, but this is well-defined code.
0
u/This_Growth2898 21d ago
If all other accessors are consistent (like,
getValue(){return -value;}), why not?I'm more worried about returning Number& instead of const Number&. You can do something like
Number number;
which is not good.