3 ms·
I think you're getting downvoted because you asserted advice as an absolute and gave no explanation why/when it applies. I happen to agree with you empirically
by phaedrus 10y ago
I think you're getting downvoted because you asserted advice as an absolute and gave no explanation why/when it applies. I happen to agree with you empirically, but I would phrase it thus: const member variables can be problematic in C++ because it disables some of the compiler-generated functions such as memberwise assignment. It violates the law of least astonishment because it seems natural to use const for the members of a small "value type" (e.g. Point, Complex, etc.) and it seems natural to store such objects in std container (e.g. std::vector), but adding the "const" on the member fields makes the object incompatible with the std containers.
- wfunction 10y agoYeah, you're saying more or less what I was thinking here. https://news.ycombinator.com/item?id=13356101 https://news.ycombinator.com/item?id=13356101 Indeed I should've written it in the original comment.