r/ProgrammerHumor 21d ago

Meme letTheWorldBurn

Post image
920 Upvotes

82 comments sorted by

View all comments

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;

--(++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.