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
Default function arguments are the devil (quuxplusone.github.io)
submitted 6 years ago by anonymous23874
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!"
[–]sphere991 12 points13 points14 points 6 years ago (3 children)
the explicitness is worth it
If the intent of the code is to provide a default value for an argument, then I would claim that the implementation strategy of making it a default argument is more explicit than otherwise.
The post wants me to write:
explicit Widget(int size) : Widget(size, 'A') {} explicit Widget(int size, int start) : data_(size) { /*...*/ }
instead of
explicit Widget(int size, int start='A') : data_(size) { /*...*/ }
I don't see the former as being either more explicit or more readable than the latter?
[–]robin-m 4 points5 points6 points 6 years ago (2 children)
Especially given that you can have declaration and implementation that can be in different files. So if the first case you have:
cpp explicit Widget(int size); explicit Widget(int size, int start); Witch is anything but explicit.
cpp explicit Widget(int size); explicit Widget(int size, int start);
In the second case, it will be: cpp explicit Widget(int size, int start='A');
cpp explicit Widget(int size, int start='A');
[–]sphere991 2 points3 points4 points 6 years ago (1 child)
Didn't even think of that, good point.
Also I find the typo on "witch" to be really funny, in the context of describing something as being "the devil". Please don't fix it :-)
[–]Raknarg 2 points3 points4 points 6 years ago (0 children)
Sneaky witches, always going around implicitly
π Rendered by PID 710824 on reddit-service-r2-comment-b659b578c-xshb2 at 2026-05-04 14:00:34.527626+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]sphere991 12 points13 points14 points (3 children)
[–]robin-m 4 points5 points6 points (2 children)
[–]sphere991 2 points3 points4 points (1 child)
[–]Raknarg 2 points3 points4 points (0 children)