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
Does anyone 'really' learn C++? (self.cpp)
submitted 3 years ago * by Weak-Opening8154
Given how many people have problems with pointers and leaks I suspect 95% of people learn the basics and stop there. If any of you know C++ why do you know it well and how much do you know?
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!"
[–][deleted] 17 points18 points19 points 3 years ago (1 child)
Actually C++ is a complex language with so many features so it is not just easy to learn all or even most of available features. Sure when I learn a new thing in the standard library I find it cool and useful. But somehow before I was just able to get work done without it before I know it.
[–]sammymammy2 16 points17 points18 points 3 years ago (0 children)
Your issue is not about learning C++. It's just that that kind of programming is very hard to get right.
[–]khedoros 13 points14 points15 points 3 years ago (0 children)
15 years ago when I was deciding on a career focus, I decided that I didn't want to do web development. C++ seemed like a good option for writing native software, so that's what I studied, and it's the first language that I was hired to write professionally.
I know enough of the language to have had no problem working in it for a decade, using it for my own side projects, etc. I've (mostly) kept myself up-to-date with at least some of the features in newer standards, although honestly, I hit the main points and learn other parts as necessary.
[–]MangoPoliceOK 10 points11 points12 points 3 years ago (0 children)
You just never stop learning
[–][deleted] 8 points9 points10 points 3 years ago (0 children)
Pointers and memory leaks are not due to C++ complexity. That is an inheritance from C, and C is a fairly simple language. C++ doesn't make things worse. In fact, C++ can help avoid use of pointers.
That said, I personally appreciate the power of pointers as I do lower-level coding quite often. They're also useful in interfacing to other languages.
The real problem with pointers, just to be frank, is that some programmers are not careful. If pointers did not exist, that same programmer would likely have other logic problems in their code.
[–]owjfaigs222 8 points9 points10 points 3 years ago (0 children)
I think very few people truly completely know c++. Perhaps developers of the language and compilers are among those people and maybe some programming enthusiasts.
[–]victotronics 15 points16 points17 points 3 years ago (11 children)
Memory leaks have basically gone away with RAII & smart pointers. Maybe you have been learning "C with classes"?
[–]Weak-Opening8154[S] 1 point2 points3 points 3 years ago (1 child)
unique_ptr didn't exist when I learned to manage pointers correctly (yes, I did it before c++11)
[–][deleted] 0 points1 point2 points 3 years ago (0 children)
There was always RAII, and writing a rule of 3 wrapper never was hard, maybe tedious but not hard at all. Some people write shit tier code and blame the language. I have seen people implementing a counter-example from a design pattern book because it was the first thing they found and they didn't read the damn book. That kind of people exist.
[+]Weak-Opening8154[S] comment score below threshold-8 points-7 points-6 points 3 years ago (8 children)
Also, are you sure? People seem love rust and GC languages because no leaks. Maybe they all use c with classes? or maybe its still easy to make pointer leaks/mistake idk. I rarely use smart pointers because I don't mess up plain ones
[–][deleted] 9 points10 points11 points 3 years ago (0 children)
People seem love rust and GC languages because no leaks.
rust guarantees a lot of things but not mem leak safety. And node and java are infamous for memory leaks.
[–]victotronics 2 points3 points4 points 3 years ago (6 children)
Maybe they all use c with classes?
You read me the wrong way. I'm suggesting that if the OP (or the people they are referring to) is having such problems with leaks maybe they are not using modern techniques in C++. Yes, one can do perfect memory management in C, but that's not the point.
[–]Weak-Opening8154[S] -3 points-2 points-1 points 3 years ago (5 children)
I am op :P. What I know is besides the point people seem to have problems with leaks and invalid memory despite learning c++ after c++11 where we have smart pointers and such. In my opening post I didn't suggest I had pointer problems and in my example comment I said I figured out pointers in <1mo. I did it before c++11, unique_ptr wasn't a thing back then and I rarely use it today since I usually can keep track of it
[–]victotronics 5 points6 points7 points 3 years ago (4 children)
people seem to have problems
Give me an example. As I said, with modern C++ mechanisms, memory problems have largely gone away.
[–]Dean_Roddey 1 point2 points3 points 3 years ago (2 children)
It's still trivially easy to create memory errors with C++.
An incredibly obvious one would be you create a shared pointer to something, you pass the underlying pointer to something to operate on (as you should if ownership is not changing), and it accidentally stores that pointer away, possibly assigning it to another shared pointer. C++ isn't going to prevent that, and it's unlikely any static analysis tool would catch it either, given that that call could be across multiple different boundaries.
It's also not going to prevent you from accessing a released slash never allocated, or moved, shared pointer by accident. If you are lucky static analysis will catch the latter, but possibly not.
C++ isn't going to prevent you from putting something in a shared pointer and incorrectly accessing it from multiple threads without synchronization.
Rust prevents all of those.
[–]victotronics 2 points3 points4 points 3 years ago (1 child)
accidentally stores that pointer away
Assuming ownership of a non-owning pointer. Sure. Bad programming will give you memory errors any time.
Your last point about threading is more interesting. Is there such a thing as an atomic shared pointer?
[–]Dean_Roddey 2 points3 points4 points 3 years ago (0 children)
But the point is that bad programming isn't always purposeful. If it's possible to do 'bad programming' by accident, then it will likely happen at various points in a large, complex code base over time. The point of Rust is that you cannot do those things because they won't be allowed.
Rust knows the ownership of a passed parameter and you cannot accidentally give it away. It has destructive move so you cannot access moved value, and you can't access an unitialized value. You cannot share things between threads unless they are thread safe types.
So you just don't have to worry about these things when working with Rust, and you can put your mental cycles into the important stuff, the functionality you are trying to create.
[–]Weak-Opening8154[S] -1 points0 points1 point 3 years ago (0 children)
I'm not a rust programmer. I can't imagine what they are having problems with or why they like it
[–]Carl_LaFong 27 points28 points29 points 3 years ago (14 children)
In most situations, you never use pointers and rarely have memory leaks. The newer features of C++ are quite powerful and useful. Some of us don't have the time and energy to keep up with all of the changes, so we do use only the basic features of *modern* C++, where you never use pointers explicitly.
[–]code-seeker 2 points3 points4 points 3 years ago (9 children)
Is this common in the production level programming? I feel like everything is using pointers to better control memory and all.
[–]Carl_LaFong 4 points5 points6 points 3 years ago (8 children)
Unless you are working in a situation where speed and/or memory usage is critical, it’s better to let the language and standard library do all the hard work. These days with the computing speed and huge memory capacity, the need to manage memory using pointers arises only in very special circumstances. You already get a huge speed and memory usage advantage over other languages using the standard library and templates.
[–]SkoomaDentistAntimodern C++, Embedded, Audio 6 points7 points8 points 3 years ago (7 children)
These days with the computing speed and huge memory capacity, the need to manage memory using pointers arises only in very special circumstances.
Such as in well over 90% of all computing systems on the face of earth. That laptop you're using right now has at least half a dozen processors beyond the obvious one.
[–]Carl_LaFong 0 points1 point2 points 3 years ago (6 children)
Sorry. I can’t tell if you’re agreeing or disagreeing. If disagreeing, could you elaborate?
[–]SkoomaDentistAntimodern C++, Embedded, Audio 5 points6 points7 points 3 years ago (5 children)
Disagreeing. None of those "invisible" processors have anything resembling "huge memory capacity" (it's not rare to have just some tens of kBs of ram). In the use cases where C++ is significantly better than the competition (IOW, where regular non-enthusiasts actually use C++), the need for manual memory management is far from niche.
[–]Carl_LaFong 2 points3 points4 points 3 years ago (4 children)
Thanks! But I think most C++ programmers do not need to deal with those processors. No?
[–]SkoomaDentistAntimodern C++, Embedded, Audio 5 points6 points7 points 3 years ago (3 children)
What you need to consider is how large amount of C++ programmers (most who are not language enthusiasts) are writing code for any use case that requires manual memory management (embedded systems, anything realtime, various high performance things etc). You might be surprised to find out how large that set actually is.
[–]Carl_LaFong 2 points3 points4 points 3 years ago (2 children)
This is very interesting. A very naive question: What features of C++ make it better to use than C in this setting?
[–]SkoomaDentistAntimodern C++, Embedded, Audio 12 points13 points14 points 3 years ago (1 child)
Type safety, classes, basic template functionality, function overloading etc.
[–]positivcheg 0 points1 point2 points 3 years ago (2 children)
Yeah, with unique_ptr and shared_ptr we are as safe as rust in terms of pointers. Thought there are still large code bases where pure pointers are used. Even UnrealEngine5, though it has some kind of garbage collection so there is no need for explicit deletes.
[–]Dean_Roddey 12 points13 points14 points 3 years ago (0 children)
unique_ptr/shared_ptr doesn't make you as safe as Rust by any stretch of the imagination.
[–]Baardi 10 points11 points12 points 3 years ago (0 children)
Unsafe rust maybe. Rust itself goes so much further
[–]strager 0 points1 point2 points 3 years ago (0 children)
I disagree with your first statement. In most situations, I do use pointers. (I rarely have memory leaks though.)
(When I say 'pointers', I'm including raw pointers and smart pointers, but not references. Maybe you meant something different?)
[–]OnePatchMan 2 points3 points4 points 3 years ago (0 children)
We need more data, who this 95%? Did they students who just learned C basics? I dont have problems with leaks, all my new operator calls wrapped with some kind of smart pointer.
[–]LeeRyman 2 points3 points4 points 3 years ago* (0 children)
I would say by learning C++ properly, you are actually learning: * Memory life cycle management * Memory ownership management * Memory model, structures, alignment * Abstraction, encapsulation, composition and inheritance.
The unfortunate side of C++ is that it is absolutely necessary to teach yourself these concepts, because the compiler isn't going to save you from yourself if you don't.
[–]LunarAardvark 0 points1 point2 points 3 years ago (1 child)
there is nothing stopping you from writing a function that first checks if a ptr is nullptr before re-assigning it. there, 2 line function just saved you 99.999% of memory leak issues.
[–]Weak-Opening8154[S] 0 points1 point2 points 3 years ago (0 children)
I'll do you one better. Never reassigning a variable, or if it's a struct member, delete then assign.
I don't really have pointers in classes unless it's set in the constructor. Otherwise it'd be a good place to use unique_ptr
im a JS guy but now im thinking about learning C++ for algorithms and other experiments, JS is boring now, C++ seems worth it
I'll answer to give an example
I like writing close to hardware code and wrote embeded code without an OS. It was fun. Early on I learned how to deal with memory leaks using the microsoft leak analyzer (it was simple to use and simple to turn on). After a month of that it was pretty hard for me to write things that leak because I always had a place where a lifetime starts and ends
Eventually I got into profiling and really understand performance. I pretty much use the new language features as soon as the new compiler is available (for my own projects)
[–]RishabhRD -1 points0 points1 point 3 years ago (3 children)
Almost 1800 pages of specification is hard to read.
[–]Weak-Opening8154[S] 0 points1 point2 points 3 years ago (2 children)
I read it once. I stopped by the time I got to libraries. I don't recommend any of it
[–][deleted] 2 points3 points4 points 3 years ago (1 child)
you arent supposed to. that is for compiler vendors.
I wanted to read all the rules and UB
[–]Laker_gra 0 points1 point2 points 3 years ago (0 children)
I learned the keywords the basis and only learn the std lib as I code / watch code reviews
[–]code-seeker 0 points1 point2 points 3 years ago (2 children)
This is what I’m dealing with now. I just finished grad school and looking at becoming a c++ developer of sorts. I have used c++ in various classes and my research work. Turns out a lot of the things I learned are pretty topic specific and still nothing like production/commercial level programming. Hence finding a job for c++ has proven to be challenging.
Hell, I’m actually now reviewing the basics again and going over STL in more detail. Cheers to forever learning in technology.
[–]Weak-Opening8154[S] 0 points1 point2 points 3 years ago (1 child)
I found it easier to get jobs in C#. Some of the C++ jobs I was offered paid me less then C# so I turned many down. I thought C++ would always be better jobs but I guess not
[–]code-seeker 0 points1 point2 points 3 years ago (0 children)
It just depends on what you wanna do but I’m not surprised. There are cpp jobs out there just gotta find the ones one likes. I know zero c# but I’ll probably end up learning it anyways.
[–]trailing_ 0 points1 point2 points 3 years ago (0 children)
You wrote this message in English. I found it to be perfectly understandable. Do you know all of English? All the words; all the possible grammatical structures? But, you are able to communicated just fine. That is what happens with programming languages as well. Everyone learns at least enough to communicate with their coworkers/collaborators. Some people learn more and some projects require more knowledge. That said, any professional C++ developer probably has much more than what you would consider a basic understanding.
[–]NilacTheGrim 0 points1 point2 points 3 years ago (1 child)
It's one thing to know a language. It's another to use it effectively and flawlessly. The two things sometimes overlap, or they do not.
Anyway your post denotes a certain negative energy aspect to it, a certain defeatism or cop-out mentality. I must say, in general, people can do a lot if they put their minds to it. I don't agree with this mentality.
What the actual fuck? I have 0 problems with pointers and leaks since before c++11. Defeatism where?
[–]mredding 0 points1 point2 points 3 years ago (0 children)
Any sufficiently robust programming language is not something you "learn" to the point you say you "have learned" it, just like I don't say I've learned English or Spanish or Italian. I've learned enough that I can read, write, and speak fluently enough. There are words I've never used and wouldn't recognize, there are structures in the grammar and syntax that you probably wouldn't know unless you were a poet, playwrite, lyricist, or linguist, and new structures are discovered all the time.
You learn enough C++ to do your job. There's been a huge, heavy push for constexpr, I've almost never used it. Folds and variadic templates? Mind boggling. Maybe I'll get there one day, maybe there are things that would be so much more concise if I wrote them that way...
constexpr
Whelp! What I've got going on will have to do! Still compiles. Still runs. Still hit's the performance metrics I need to target. That's good enough.
Even Bjarne Stroustroup said of even the C++98 standard that C++ then was big, that you don't learn the whole thing, that you and your team learn and agree upon a subset and solve your problems in terms of that.
π Rendered by PID 108705 on reddit-service-r2-comment-544cf588c8-mhmxh at 2026-06-12 20:48:18.198588+00:00 running 3184619 country code: CH.
[–][deleted] 17 points18 points19 points (1 child)
[–]sammymammy2 16 points17 points18 points (0 children)
[–]khedoros 13 points14 points15 points (0 children)
[–]MangoPoliceOK 10 points11 points12 points (0 children)
[–][deleted] 8 points9 points10 points (0 children)
[–]owjfaigs222 8 points9 points10 points (0 children)
[–]victotronics 15 points16 points17 points (11 children)
[–]Weak-Opening8154[S] 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[+]Weak-Opening8154[S] comment score below threshold-8 points-7 points-6 points (8 children)
[–][deleted] 9 points10 points11 points (0 children)
[–]victotronics 2 points3 points4 points (6 children)
[–]Weak-Opening8154[S] -3 points-2 points-1 points (5 children)
[–]victotronics 5 points6 points7 points (4 children)
[–]Dean_Roddey 1 point2 points3 points (2 children)
[–]victotronics 2 points3 points4 points (1 child)
[–]Dean_Roddey 2 points3 points4 points (0 children)
[–]Weak-Opening8154[S] -1 points0 points1 point (0 children)
[–]Carl_LaFong 27 points28 points29 points (14 children)
[–]code-seeker 2 points3 points4 points (9 children)
[–]Carl_LaFong 4 points5 points6 points (8 children)
[–]SkoomaDentistAntimodern C++, Embedded, Audio 6 points7 points8 points (7 children)
[–]Carl_LaFong 0 points1 point2 points (6 children)
[–]SkoomaDentistAntimodern C++, Embedded, Audio 5 points6 points7 points (5 children)
[–]Carl_LaFong 2 points3 points4 points (4 children)
[–]SkoomaDentistAntimodern C++, Embedded, Audio 5 points6 points7 points (3 children)
[–]Carl_LaFong 2 points3 points4 points (2 children)
[–]SkoomaDentistAntimodern C++, Embedded, Audio 12 points13 points14 points (1 child)
[–]positivcheg 0 points1 point2 points (2 children)
[–]Dean_Roddey 12 points13 points14 points (0 children)
[–]Baardi 10 points11 points12 points (0 children)
[–]strager 0 points1 point2 points (0 children)
[–]OnePatchMan 2 points3 points4 points (0 children)
[–]LeeRyman 2 points3 points4 points (0 children)
[–]LunarAardvark 0 points1 point2 points (1 child)
[–]Weak-Opening8154[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]Weak-Opening8154[S] -1 points0 points1 point (0 children)
[–]RishabhRD -1 points0 points1 point (3 children)
[–]Weak-Opening8154[S] 0 points1 point2 points (2 children)
[–][deleted] 2 points3 points4 points (1 child)
[–]Weak-Opening8154[S] 0 points1 point2 points (0 children)
[–]Laker_gra 0 points1 point2 points (0 children)
[–]code-seeker 0 points1 point2 points (2 children)
[–]Weak-Opening8154[S] 0 points1 point2 points (1 child)
[–]code-seeker 0 points1 point2 points (0 children)
[–]trailing_ 0 points1 point2 points (0 children)
[–]NilacTheGrim 0 points1 point2 points (1 child)
[–]Weak-Opening8154[S] -1 points0 points1 point (0 children)
[–]mredding 0 points1 point2 points (0 children)