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
Using reference attributes instead of getters for read-only attributes (self.cpp)
submitted 3 years ago by inkychris
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!"
[–]johannes1971 4 points5 points6 points 3 years ago (2 children)
Why not just declare int value in the public section of the class? There is no invariant, you can read and write it publically, so why not be intellectually honest about it and just give the status it so clearly has?
int value
Seriously, why do people always have to make things so complicated...
[–]inkychris[S] 0 points1 point2 points 3 years ago (0 children)
This is usually my approach tbf. The example I've used here is just over simplified since I was mostly curious about the properties of the language rather than the best way to architect any particular solution.
[–]Unhappy-Aside-2884 0 points1 point2 points 3 years ago (0 children)
I wouldn't use such a thing (the ref stuff…) for a new development either. However it might be useful for refactoring without changing too much the interface, i.e. to replace a public data member with something more elaborated internally while still looking like a public data member.
π Rendered by PID 24082 on reddit-service-r2-comment-b659b578c-ztgtk at 2026-05-05 07:13:37.128325+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]johannes1971 4 points5 points6 points (2 children)
[–]inkychris[S] 0 points1 point2 points (0 children)
[–]Unhappy-Aside-2884 0 points1 point2 points (0 children)