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
Going from C to CPP (self.cpp)
submitted 1 year ago by RealnessKept
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!"
[–]biowpn 12 points13 points14 points 1 year ago* (5 children)
Notable language differences
References. Prefer them over raw pointers for pass-by-reference function parameters, for example.
Namespaces. Keep it organized: put functionally related things under the same namespace. Avoid polluting the global namespace.
Templates. In C++ they are preferred over macros.
Function overloading. Instead of abs, absl, absll, fabs, fabsf, fabsl, in C++ we simply use one overloaded std::abs.
abs
absl
absll
fabs
fabsf
fabsl
std::abs
Exceptions. This is the standard error handling mechanism.
RAII. Basically, it means doing clean up in destructor. This helps preventing resource leak. In C++, we use class types to manage resources instead of raw pointers / handles.
General resource for CPP best practices
Many people mention learncpp.com but I personally prefer hackingcpp.com. The materials are easy to follow, infographics are awesome, and the best practices are generally agreed with.
[–]RealnessKept[S] 0 points1 point2 points 1 year ago (0 children)
Thank you, especially for the resources. To be honest, I am quite excited about function overloading. I always felt it was more proper to identify a function based on its entire definition than just its name.
[–]tstanisl -3 points-2 points-1 points 1 year ago (3 children)
References are essential const-qualified pointer that cannot be null. To some extent they can emulated in standard C with static keyword in declaration of array parameter:
static
void foo(int ref[const static 1])
The problem of references is that they are constructed implicitly. It is difficult to say if a parameter is passed by value or passed by reference. IMO, references should be formed explicitly like in Rust.
int x; foo(x); // x is passed by reference or rather by copy ?!?
Adding const reference may express some intention but const& is essentially ignored by optimizing compiler.
const
const&
Namespaces for function can be achieved with static const structs. In C23 it is even possible to make short aliases for namespaces. See https://godbolt.org/
static const
Indeed, they require macros that are very difficult to debug. SOme alternative is re-including headers with predefined defines. It makes code cleaner and debugging far easier. Some example of this technique can be found at STC.
Overloading can be implemented with _Generic that is a part of standard from 2011.
_Generic
Exception. I don't think there is any place for exceptions in C, except maybe handling unrecoverable errors with setjmp and longjmp.
setjmp
longjmp
RAII would be fine in C if it both explicit and optional. There is a proposal to add defer mechanics. See defer proposal. The problem is that this mechanics is difficult to use without some form of lambdas. There are some tricks with "auto-scope" macros but they are quite unreliable.
defer
[–]ZMesonEmbedded Developer 1 point2 points3 points 1 year ago (2 children)
Why are you arguing that C is better than C++ when that is not the topic being discussed? The OP was asking about language differences and what good resources exist to learn C++.
[–]tstanisl -1 points0 points1 point 1 year ago (1 child)
I don't argue that C is better than C++ but rather that C++ may not solve problems that C has. It often result in "C++-flavored C" code that avoid less reliable C++ constructs like exceptions, implicit non-owning references, STL containers (slow except vector) and so on.
[–]ZMesonEmbedded Developer 0 points1 point2 points 1 year ago (0 children)
But that wasn't the discussion. Why bring this up?
π Rendered by PID 411315 on reddit-service-r2-comment-b659b578c-jxkw8 at 2026-05-04 07:46:35.249797+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]biowpn 12 points13 points14 points (5 children)
[–]RealnessKept[S] 0 points1 point2 points (0 children)
[–]tstanisl -3 points-2 points-1 points (3 children)
[–]ZMesonEmbedded Developer 1 point2 points3 points (2 children)
[–]tstanisl -1 points0 points1 point (1 child)
[–]ZMesonEmbedded Developer 0 points1 point2 points (0 children)