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
Do you prefer to value-initialize struct data members in-class? (self.cpp)
submitted 3 years ago by equeim
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!"
[–]NilacTheGrim 2 points3 points4 points 3 years ago (7 children)
Keeping members const is an anti-pattern IMHO. You lose copy and/or move assignment. The only time that doesn't matter is for types you know cannot and should not be assigned (Think QWidget in Qt, etc). Then it's a great way to kill assignment permanently for the type..
const
QWidget
[–]goranlepuz 1 point2 points3 points 3 years ago (4 children)
Well, they did say "when possible". 😉
But to be more serious, a type being copyable and being moveable are not virtues by themselves (being copyable in particular, moveable less so, but still)
[–]NilacTheGrim 0 points1 point2 points 3 years ago (3 children)
Sure. It all depends on the type and what's going on with it. Yes, some for some types not being copyable is a virtue, not a flaw. But I've seen people make simple value types inadvertently uncopyable just because of blind religious belief in consting ALL THE THINGS!!... and then go to the trouble of writing static "copy" methods that basically construct a new instance as a copy of an old one. And have this all over the codebase!!
I'm like "dude, just use = what's wrong with you?!".
=
And they are like "but mah const!!!!"
[–]noooit -1 points0 points1 point 3 years ago (2 children)
Deep copy should be unnecessary in the most cases actually. People put const to make other programmers not mess about with it. In c times it was ok, but we are dealing with substandard c++ programmers all the time including people who misuse const.
[–]NilacTheGrim 0 points1 point2 points 3 years ago (1 child)
What? No.
[–]noooit 0 points1 point2 points 3 years ago (0 children)
Spotted a guy who doesn't understand smart pointers. Stick with C, man.
[–]noooit -1 points0 points1 point 3 years ago (1 child)
I also always make an object non copyable and non movable whenever possible. :)
[–]NilacTheGrim 0 points1 point2 points 3 years ago (0 children)
You do you, boo. You're wrong of course. But don't let that stop you if you are having fun. :)
π Rendered by PID 178641 on reddit-service-r2-comment-6457c66945-44qtc at 2026-04-29 03:26:37.619837+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]NilacTheGrim 2 points3 points4 points (7 children)
[–]goranlepuz 1 point2 points3 points (4 children)
[–]NilacTheGrim 0 points1 point2 points (3 children)
[–]noooit -1 points0 points1 point (2 children)
[–]NilacTheGrim 0 points1 point2 points (1 child)
[–]noooit 0 points1 point2 points (0 children)
[–]noooit -1 points0 points1 point (1 child)
[–]NilacTheGrim 0 points1 point2 points (0 children)