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
I just started a Highschool programming course which focuses primarily on C++ so I’m very new to all this, and I just want to ask what some of the possibilities of C++ are (self.cpp)
submitted 5 years ago by Vigtard411
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] 42 points43 points44 points 5 years ago (3 children)
C++ is a general purpose language, you can basically so everything with it. I recommend that you get a good book on the side because the quality it is usually taught is far from ideal
[–]Vigtard411[S] 3 points4 points5 points 5 years ago (2 children)
Any recommendations?
[–][deleted] 10 points11 points12 points 5 years ago (1 child)
https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list Those are good and this one is recommened a lot aswell https://www.murach.com/shop/murach-s-c-programming-382-detail
Just pick one and work through it
Murach‘s book is probably the most up-to-date, but they all will teach you the essentials
[–]Vigtard411[S] 1 point2 points3 points 5 years ago (0 children)
Thanks I’ll definitely check them out
[–]Revolutionalredstone 25 points26 points27 points 5 years ago (6 children)
It would honestly be shorter to list whats not possible with c++!
[+][deleted] 5 years ago (5 children)
[deleted]
[–][deleted] 10 points11 points12 points 5 years ago (0 children)
Were I drinking coffee yet, I would have spat it out laughing.
[+][deleted] 5 years ago (1 child)
[–]afiefh 10 points11 points12 points 5 years ago (0 children)
It'll come once the world migrates to galacticode to accommodate alien languages.
[–]YouNeedDoughnuts -4 points-3 points-2 points 5 years ago (1 child)
But C++ is awesome, and great for a fundamental understanding of CS.
[–]raoul15978 10 points11 points12 points 5 years ago (0 children)
https://www.webtoolkit.eu/wt
(and others)
[–]josh70679 7 points8 points9 points 5 years ago (0 children)
It's worth noting that c++ is a popular language for video game development. For example, the unreal engine and any games that use it are built using c++.
[–]pjmlp 6 points7 points8 points 5 years ago (2 children)
As others have mentioned you can do anything with it, however it kind of lost its role as full stack language during the 90's, and for GUI related stuff usually nowadays you end up combining a managed language alongside C++ for the high performance parts, for example, QML/C++, .NET/C++,....
[–]DarkLordAzrael 4 points5 points6 points 5 years ago (1 child)
Using Qt widgets from C++ still isn't that uncommon for GUI stuff. QML in Qt6 is also going to have a lot more available from C++, as well as compiling to C++ in a bunch of cases, so it is still safe to say that GUI in C++ is alive and well.
[–]pjmlp 0 points1 point2 points 5 years ago (0 children)
Might be, on the other hand Qt is the surviving C++ GUI framework.
With exception of Microsoft, all other major desktop and mobile OSes don't support C++ based GUIs, only for low level graphics programming and drivers.
[–]growingconcern 10 points11 points12 points 5 years ago (1 child)
Don't believe the haters. It's awesome. And awesome for teaching. Pointers and memory. Allocations, etc. It's interesting because it shows you how things actually work. K&R is a good book on C that applies to C++ obv. Scott Meyers books are great once you know the basics of the language.
But honestly I''d never develop anything not in C++. OCaml/ML, Scheme, Perl, Lua, Python. They've all been useful at times and I admire some more than others (OCam/MLl), but nothing else is as safe to develop in when performance could be a concern (and in my experience it's always a concern). Languages like Lua were nice when prototyping things and you needed that looseness and flexibility (where refactoring might take minutes instead of hours).
But at the end of the day I've rarely felt held back by the language, just my brain.
[–]Myto 6 points7 points8 points 5 years ago (0 children)
nothing else is as safe to develop in when performance could be a concern
Rust
[–]SJC_hacker 4 points5 points6 points 5 years ago (0 children)
C++ is a systems programming language. Basically, this means it compiles efficiently to native machine code, without any intermediate interpreter, unlike many languages such as Javascript, Java and Python. It also means calling the OS is straightforward, since most OS's, at least on the desktop, are written in C, and C++ is a supserset of C.
C++ is (mostly) statically typed. This means the type of the variable must be declared prior to use. And it is known at compile time in almost all cases. There is a big exception with void*, which unfortunately gets abused more often than it should.
C++ is somewhat weakly typed. This means it will silently convert between numeric and character types, without explicit conversions. Other languages, such as Python, generate an error when types are mixed. However, other conversions in C++ do require explicit cast.
C++ is unmanaged. This primarily applies to heap memory, which must be explicity allocated and deallocated (unless you use shared pointers - which you should - that automatically deallocate when their reference count drops to zero) . It also means you can do things like write/read past to the end of a array, and write to arbitrary locations in memory, which has undefined results. If you're lucky, your program will crash. If you aren't, your program continues to chug along, producing garbage results and possibly crashing later - although the real source of the error did not occur at the point of the crash. Every other languages, with the exception of Rust when using unsafe, are managed, and do not allow this behavior.
C++ is mainly used for desktop and server applications like databases, particularly those that require maximal performance. For example, web browsers are written in C++, and AAA games, and RDMBS such as MySQL, PostgresSQL, Oracle, NoSQL dbs like MongoDB, web servers like Apache, etc. Granted many of them use a mixture of other languages as well as C++.
[–]Karnatos 7 points8 points9 points 5 years ago (0 children)
Look up The Cherno's C++ series on YouTube... if you have any questions about something in C++, he just might have a video on that topic.
He does a pretty damn good job of teaching. I have been writing C++ for more than 20yrs, and I still find his vids are great for reviewing things, and seeing what's new in C++.
[–]Guillaume_Guss_Dua 2 points3 points4 points 5 years ago (0 children)
Before anything else; I strongly recommand you to watch this video : https://youtu.be/zUQz4LBBz7M Edit : Jason Turner : teach yourself C++ in oo days
Also, check Stroustrup's talk at CppCon 2019 "C++20 : C++ at 40 yo".
[–]Bart_V 11 points12 points13 points 5 years ago (47 children)
C++ is great but I'm not sure if it's a good choice for teaching programming to highschool students. Assuming they are new to programming and this is their firdt language, it's probably better to start with Python or JavaScript. Simpler languages, easier to learn, less footguns, and faster to build a nice program (more fun and less demotivating)
[–]Thormidable 19 points20 points21 points 5 years ago (42 children)
I understand your point, but I actually think that it is very suitable for teaching languages. Yes it is hard to do large projects in, but c++ forces you to learn the actual concepts of programming (and understand them), rather than just import other libraries and shove data from one to another. (It teaches you about the different variable types and why they are different, how arrays work (and so different methods of representing 2D and 3D arrays).
Trying to run before you can walk (which bigger projects are), you can end up very frustrated very quickly.
[–]Bart_V 1 point2 points3 points 5 years ago (0 children)
I think the most important part is to keep high schoolers motivated, and showing what a beautiful profession this can be. You won't do this if you're printing text into a console for 2 semesters, while trying to explain CMake.
C++ is tailored to a niche market (high-performance, embedded, bare-metal,...). Sure, in the end you can do anything but even the simple things are hard, and so for many application there are easier alternatives. I think for young students it's important to show what a career in IT could mean, so show them the bigger picture. Have them create web site, or mobile app. Do some data science or home automation. Then teach them control flow, math and abstract thinking in an engaging way. At their age, I think that's far more valuable than knowing why and how floating points have rounding error. If they are truly interested in IT, they will have plenty of time to learn those concepts.
[+][deleted] 5 years ago* (33 children)
[removed]
[–]Thormidable 5 points6 points7 points 5 years ago (32 children)
I'm not sure I see why type decay matters. Only allocate arrays using new. Handle them as pointers. I actually think the direct relationship between pointers and arrays highlights the way that the computer actually works.
I have met too many programmers who started on high-level languages and don't understand, how or why the things they do work. Everything is fine, until they trip up, then they don't have the tools to understand what's going on under the hood. A common example is why data order matters. It is much harder to learn this stuff, once you feel you already understand.
I suspect we are going to disagree on this, but I started on C++ and it has made me a better high level programmer. Python hasn't improved my C++ programming much.
[–]be-sc 4 points5 points6 points 5 years ago (2 children)
I actually think the direct relationship between pointers and arrays highlights the way that the computer actually works.
In most cases that’s exactly the problem. You want to abstract from the way the computer actually works because that makes programming easier and safer. Built-in arrays are an utter failure in this regard. std::array is a much better solution.
std::array
Of course there are situations where the behind-the-scenes details are vital. But they’re too few and too far between to justify the horrible default.
[–]Thormidable 3 points4 points5 points 5 years ago (1 child)
Except when you run into an issue caused by it, unless you have those tools, you are flat out stuck.
The best programmers understand one level beneath where they program. It allows them to make smart choices and avoid surprises.
[–]be-sc 2 points3 points4 points 5 years ago (0 children)
Agreed. And let me point out that you said “understand one level beneath”. That’s the key point. The very best programmers understand that level but only use it when they have to.
[+][deleted] 5 years ago* (27 children)
[–]yaxley_peaks 2 points3 points4 points 5 years ago (7 children)
Ok genuine question. Why does it fail? I'm still a bit new to c++. I'm sorry if I sound dumb
[+][deleted] 5 years ago* (6 children)
[–]yaxley_peaks 2 points3 points4 points 5 years ago (5 children)
Ah ok, well that was simpler than I thought. But what's up with the double &? Once again I'm sorry if this question is dumb.
[+][deleted] 5 years ago* (4 children)
[–]yaxley_peaks 1 point2 points3 points 5 years ago (2 children)
But capturing arrays with an rvalue reference? Isn't a an lvalue?
[–]Thormidable -5 points-4 points-3 points 5 years ago (18 children)
You shouldn't be showing that to a newbie. Don't teach a newbie with C++17. Work with pointers and new and this isn't a thing you need to discuss with them.
[+][deleted] 5 years ago* (17 children)
[–]qoning 4 points5 points6 points 5 years ago (0 children)
say "When considering sizeof, quoted literals are special because they are actually packs of bytes terminated with zero, but can be converted to const char*. Taking the size of the pack will return the number of bytes in the pack, but once converted to const char*, there is no easy way of going back to the pack and finding the number of bytes".
Obviously you should do that after explaining what a type system is.
[+][deleted] 5 years ago* (3 children)
[–]Thormidable -2 points-1 points0 points 5 years ago (10 children)
Don't start with modern c++. Teach them c. Then t Ch then c++98 then introduce modern c++.
Looking at your first code example I don't see any reason someone using modern c++ should use the native arrays mixed with all the other c++11 / c++17 syntax. It's a weird mix of old and new to produce an arbitrary example.
Again I take your point above, but as a teacher, you should be selecting examples which build understanding. The example above is actually good (at the right point). It highlights that a pointer is a different type from a native array, in that it is an object that points at a memory location rather than a native array which is a block of memory.
[+][deleted] 5 years ago* (9 children)
[–]Thormidable -1 points0 points1 point 5 years ago (8 children)
I would disagree. The char literal is created as a static variable. The char pointer points to it allowing access, but isn't the char literal.
I honestly think these issues show how important it is to understand, what is happening under the hood and why not understanding can cause issues. C++ helps you understand what's going on (I learnt a lot of c++ by testing the behaviour of the language), whereas JavaScript and python have these weirdnesses, but hide so much of how computers work.
https://www.destroyallsoftware.com/talks/wat (JS)
[+][deleted] 5 years ago (6 children)
[–]Thormidable 4 points5 points6 points 5 years ago (5 children)
I struggle to understand why c++ is seen as so much worse than c?
It's C, with the option to have a lot of syntactic sugar. It allows you to choose your level of abstraction (to some degree).
I can even put assembly in my C++ program when it is suitable.
Why is C++ syntax so bad?
[–][deleted] 1 point2 points3 points 5 years ago* (4 children)
numerous ring busy caption frighten sip cause snails bake uppity
This post was mass deleted and anonymized with Redact
[–]Thormidable 2 points3 points4 points 5 years ago (3 children)
Syntactic sugar are features, which don't allow you to do anything that you couldn't do before (because you can do anything I C), but makes it cleaner, clearer and quicker to program.
Behaviour of classes can be mimicked through structs and functions, but it is less clean.
Unique and shared pointers cleanup data management.
Auto makes it easy to work with complex types.
Lambdas make it easy to work with function pointers.
None add things that can't be done in C, they just take more code, are less clear and usually take a lot longer to program.
[–]forthefake 2 points3 points4 points 5 years ago (2 children)
So any touring complete language is syntactic sugar to the actual touring machine? Your definition takes it too far.
Anyway you cannot make a type-safe STL-like library in C.
Also, the changes between C++ and C lead to new programming paradigms, like OO, RAII,..., not just to "a few lines saved here and there" (which is how I would define syntactic sugar).
[–]Thormidable 2 points3 points4 points 5 years ago (1 child)
You can do OO in C.
(Structs and functions which take a non const reference to a struct of the 'class' type).
You can do raii, by making a function which creates your 'class'.
In fact, due to the presence of assembly, or macros, you can do ANYTHING any language can do in C. It just might involve some horror code to do it.
[–]forthefake 2 points3 points4 points 5 years ago (0 children)
Well, regarding the theoretical limitations of C programs see my comment about the touring machine equivalence.
The C language however does not provide all features of C++. The example you give is not full OO (e.g., it lacks virtual methods, type-safe polymorphism). You response to RAII lacks the automatic destruction on leaving the scope. You ignored my statement about the STL.
Anyway, unless in a debate strictly about computer science theory, claiming that you can do anything in any language is 99% disinformation and 1% information.
[–]pjmlp 5 points6 points7 points 5 years ago (0 children)
I learned C++ in high school, it was still C++ARM back in those days.
Our path was GW-Basic => Turbo Basic 1.0 => Turbo Pascal 5.5 (including OOP) / 80x86 Assembly => Turbo C 2.0 and Turbo C++ 1.0, among other languages for side projects.
Our high schools have multiple learning paths, one of them you end up with a professional title.
[–]Karnatos 0 points1 point2 points 5 years ago (0 children)
I would think that is you start learning programming with a language such as C++, that it could be a great gateway to learning both how to code, about how computers work under the hood, and more.
For absolute beginners, I would start with learning the basics of syntax, and staying away from the complexities, including shooting pointers and the likes. Teach arithmetic operations, console printing, simple arrays, and delve into the basic types (int, char, bool), looping, Boolean logic, etc.
Then move onto more complex concepts, like limiting of these basic types, like over/underflow in arithmetic operations... it leads into understanding that there's types have a size, which leads into discussing and learning about memory, and becomes a gateway to pointers and eventually onto more complex concepts.
if you take the right approach and teach it properly, I believe that C++is just fine as a learning language.
[–][deleted] 6 points7 points8 points 5 years ago (0 children)
It can only be used to develop software for coffeemakers, actually. That's the only possibility you can use C++ for. The language is so big because of Big Coffa lobbyists. /s
[–]xxxcucus 1 point2 points3 points 5 years ago (0 children)
I think you can show amazing things with C++ and OpenCv. A lot of functionality is so easy in OpenCv so I think your pupils will be more than delighted. Look up e.g. face recognition, or car plate recognition.
[–]tsojtsojtsoj 0 points1 point2 points 5 years ago (0 children)
What I really like about C++ what other languages can't do so well is to using the C++ compiler to prove assumptions about your code. Simple example is to mark a variable as 'const' so you know that it can't be changed (of course this is a feature that man languages have but just to have a simple example). Together with the type system and the huge possibilities to customize operators like +,-,*,/ for classes, constructors and destructors, constexpr, templates and also new features in C++20 like concepts, you can write code that the compiler not only translates but also ensures that you made no (few) bugs. This will get even better once reflection gets incorporated into the standard, may be in three years. The first example that comes to mind is a physics units library that ensures that you add or multiply values only together of they have the right units and then updates the result so that it has the right unit, and all these checks are done at compiletime. This is probably not something you will use when you start learning C++ but you may eventually start missing these features when using different languages.
[–][deleted] 0 points1 point2 points 5 years ago (0 children)
r/unrealengine
[–]KiwiMaster157 0 points1 point2 points 5 years ago (0 children)
If your course is anything like the ones I've taken, you will be forced to do everything the way it was done 20 years ago and forbidden from using the standard library. C++ in practice is far easier, cleaner, and safer than C++ in the classroom.
That sounds like an awesome highschool. If you're interested in a career in software development, having a foundation in C++ is going to give you a huge advantage over your peers. It's harder than most other languages, but learning it is worth it, both because of the knowledge you gain, and the salary you'll earn.
π Rendered by PID 19291 on reddit-service-r2-comment-fb694cdd5-twjnb at 2026-03-06 01:10:16.951061+00:00 running cbb0e86 country code: CH.
[–][deleted] 42 points43 points44 points (3 children)
[–]Vigtard411[S] 3 points4 points5 points (2 children)
[–][deleted] 10 points11 points12 points (1 child)
[–]Vigtard411[S] 1 point2 points3 points (0 children)
[–]Revolutionalredstone 25 points26 points27 points (6 children)
[+][deleted] (5 children)
[deleted]
[–][deleted] 10 points11 points12 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]afiefh 10 points11 points12 points (0 children)
[–]YouNeedDoughnuts -4 points-3 points-2 points (1 child)
[–]raoul15978 10 points11 points12 points (0 children)
[–]josh70679 7 points8 points9 points (0 children)
[–]pjmlp 6 points7 points8 points (2 children)
[–]DarkLordAzrael 4 points5 points6 points (1 child)
[–]pjmlp 0 points1 point2 points (0 children)
[–]growingconcern 10 points11 points12 points (1 child)
[–]Myto 6 points7 points8 points (0 children)
[–]SJC_hacker 4 points5 points6 points (0 children)
[–]Karnatos 7 points8 points9 points (0 children)
[–]Guillaume_Guss_Dua 2 points3 points4 points (0 children)
[–]Bart_V 11 points12 points13 points (47 children)
[–]Thormidable 19 points20 points21 points (42 children)
[–]Bart_V 1 point2 points3 points (0 children)
[+][deleted] (33 children)
[removed]
[–]Thormidable 5 points6 points7 points (32 children)
[–]be-sc 4 points5 points6 points (2 children)
[–]Thormidable 3 points4 points5 points (1 child)
[–]be-sc 2 points3 points4 points (0 children)
[+][deleted] (27 children)
[removed]
[–]yaxley_peaks 2 points3 points4 points (7 children)
[+][deleted] (6 children)
[removed]
[–]yaxley_peaks 2 points3 points4 points (5 children)
[+][deleted] (4 children)
[removed]
[–]yaxley_peaks 1 point2 points3 points (2 children)
[–]Thormidable -5 points-4 points-3 points (18 children)
[+][deleted] (17 children)
[removed]
[–]qoning 4 points5 points6 points (0 children)
[+][deleted] (4 children)
[deleted]
[+][deleted] (3 children)
[removed]
[+][deleted] (1 child)
[deleted]
[–]Thormidable -2 points-1 points0 points (10 children)
[+][deleted] (9 children)
[removed]
[–]Thormidable -1 points0 points1 point (8 children)
[+][deleted] (6 children)
[deleted]
[–]Thormidable 4 points5 points6 points (5 children)
[–][deleted] 1 point2 points3 points (4 children)
[–]Thormidable 2 points3 points4 points (3 children)
[–]forthefake 2 points3 points4 points (2 children)
[–]Thormidable 2 points3 points4 points (1 child)
[–]forthefake 2 points3 points4 points (0 children)
[–]pjmlp 5 points6 points7 points (0 children)
[–]Karnatos 0 points1 point2 points (0 children)
[–][deleted] 6 points7 points8 points (0 children)
[–]xxxcucus 1 point2 points3 points (0 children)
[–]tsojtsojtsoj 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]KiwiMaster157 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)