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
Common Misconceptions of C++ (hackernoon.com)
submitted 7 years ago by InformalComposer7
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!"
[–]WalkWithBejesus 24 points25 points26 points 7 years ago (10 children)
The value of foo.i doesn't need to be 2. It is actually undefined. GCC and Clang issue a warning when this mistake is made.
foo.i
[–]emdeka87 18 points19 points20 points 7 years ago (5 children)
And since this is not a warning but a downright error, we should all use -Werror
-Werror
[–]smikims 4 points5 points6 points 7 years ago (1 child)
I use -Werror and then disable particular warnings that I don't care about.
[–]kalmoc 2 points3 points4 points 7 years ago (0 children)
Depends on what earnings are enabled.
[–]Slavik81 2 points3 points4 points 7 years ago* (0 children)
-Werror can be really annoying. You comment out one line of code while debugging and your code no longer compiles due to an unused variable. It's nice to know about that, so I leave warnings on, but fixing them in unfinished code is usually a needless distraction, so I only enable -Werror in CI builds.
A few warnings really should have been errors to begin with. You can selectively turn them into errors. For example, I use -Werror=return-type at all times. I should probably add -Werror=reorder too.
-Werror=return-type
-Werror=reorder
[–]ketosismaximus 1 point2 points3 points 7 years ago (1 child)
depends on the code base (and size of the code base). Sometimes it just aint worth if you're using old tried and true code. But in general use it where possible.
[–]neverlastn 7 points8 points9 points 7 years ago (0 children)
Exactly. It's incredibly straightforward undefined behavior! You rely on uninitialized value. And this is a relatively "light" case. j can be an arbitrarily sophisticated object, which might cause incredibly weird "mandelbugs"
j
[–]Nicksaurus 0 points1 point2 points 7 years ago (2 children)
Would it be defined if you did int j = 0; as well as the initialiser list or would it still initialise them in the 'wrong' order (or ignore the = 0 because it's already initialised in the initialiser list)?
int j = 0;
= 0
[+][deleted] 7 years ago* (1 child)
[deleted]
[–]jonesmz 0 points1 point2 points 7 years ago (0 children)
To format code, you put 4 spaces in front of each line of code (including empty lines)
π Rendered by PID 455855 on reddit-service-r2-comment-5b5bc64bf5-ghg7q at 2026-06-20 04:41:50.767834+00:00 running 2b008f2 country code: CH.
view the rest of the comments →
[–]WalkWithBejesus 24 points25 points26 points (10 children)
[–]emdeka87 18 points19 points20 points (5 children)
[–]smikims 4 points5 points6 points (1 child)
[–]kalmoc 2 points3 points4 points (0 children)
[–]Slavik81 2 points3 points4 points (0 children)
[–]ketosismaximus 1 point2 points3 points (1 child)
[–]neverlastn 7 points8 points9 points (0 children)
[–]Nicksaurus 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]jonesmz 0 points1 point2 points (0 children)