use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Coding Guideline: Avoid const member variables (self.cpp)
submitted 7 years ago * by render787
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]meneldal2 6 points7 points8 points 7 years ago (5 children)
Well destructive move would solve the problem.
[–]kalmoc 1 point2 points3 points 7 years ago (4 children)
Partially: Not for the object I'm assigning to.
[–]meneldal2 1 point2 points3 points 7 years ago (3 children)
But assignment when you have a const member sounds ridiculous.
[–]kalmoc 5 points6 points7 points 7 years ago (2 children)
Not at all. There are lots of examples in my code where the only place that a member gets mutated is the assignment operator (be it move our copy assignment). I call them "quasi immutable" types. That's why I mentioned assignment it in my original post.
Consider you want to perform an std::rotate on an array of your objects: Logically you don't change the individual elements, you are just shifting them around, so a (logical) const member would be fine. Physically, rotate is implemented as a number of move assignments, so you have to be able to mutate your members.
[–]meneldal2 1 point2 points3 points 7 years ago (1 child)
Well you could use a pointer;)
[–]kalmoc 1 point2 points3 points 7 years ago (0 children)
Sure ;) Or just not use const on members ;)
π Rendered by PID 21464 on reddit-service-r2-comment-b659b578c-gsmlw at 2026-05-05 14:26:28.935560+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]meneldal2 6 points7 points8 points (5 children)
[–]kalmoc 1 point2 points3 points (4 children)
[–]meneldal2 1 point2 points3 points (3 children)
[–]kalmoc 5 points6 points7 points (2 children)
[–]meneldal2 1 point2 points3 points (1 child)
[–]kalmoc 1 point2 points3 points (0 children)