r/cpp_questions • • Oct 29 '24

OPEN US state told our company to not develop in C++

486 Upvotes

I am working for a US cyber security company and the state told our company to change our application's language which already has been developed by C++, because it's an unsafe language. This is a 3-years requirement.

This decision made me think about my career. Is C++ considered a bad language now?!

Note: Our team says we should pick Rust but it's not confirmed


r/cpp_questions • • Aug 26 '20

OPEN If you offer to pay money to have someone do your homework or take your exams I will ban you.

465 Upvotes

I can't believe I actually have to say it.

But if this is the case, then do the most decent and self-respectable thing you can do and switch majors instead; take a leave and come back to college when you're ready to take it seriously; do something, anything else to get yourself in order. An education is not just a piece of paper.

DO NOT insult the hard work the members of this community have put in to get to where they are, both your fellow classmates who are asking honest questions, and the seasoned professionals who volunteer their time to respond.


r/cpp_questions • • Jan 07 '22 Popcorn

OPEN Best resources to learn C++

441 Upvotes

Title basically sums it up. I have to take a C++ class in a month and would like to start learning it now to give me a head start when the class starts. I’m already familiar with python. What videos or other sources do you recommend for me to learn it?


r/cpp_questions • • Apr 12 '26

OPEN Is Linus Torvalds just a dinosaur about C++?

409 Upvotes

I have recently started learning C as a hobby and it’s very interesting, but I quickly have begun to understand the thought process that must have lead to C++. Even in simple projects like Tetris and a CHIP-8 interpreter it becomes a little annoying to have a struct, a pointer to that struct, and a separate function that has to include an ‘object’ (I don’t know what you call it in c) of the struct that you have to pass to every function call. One of the reasons I chose C for a language is because of how highly it is praised by the likes of Linus Torvalds, and naturally his less-than-flattering opinions of C++ have become apparent to me. Do you think Torvalds has a point about C++ and OOP in general, at least for his main domain of kernel level code? If not at all, (ie if you think C++ is an objective improvement) do you think it’s worth it to learn C before hand anyway?


r/cpp_questions • • May 28 '20

OPEN List of Resources to learn (modern) C++

352 Upvotes

I've not been a member of this subreddit for long, but I swear I must have seen questions like "what resources do you recommend?" or "Best way to learn C++ for a complete beginner?" a hundred times already and that's not an overstatement.

I don't blame people for asking those questions; it's completely fine, we are all here to learn. And I humbly - as I am not in any way better than any of the people in this sub - ask the kind people responsible for this sub to pin this post or create a post of their own containing resources to learn C++.

Anyway, here is the content:

My own recommendations:

Obviously all of this involves practice, so by saying "learn by reading" I mean having that as a complement, not a complete replacement.

With that being said, here are extra resources that I found very useful:

  • [Book] Effective Modern C++ by Scott Meyers - I don't consider this one a C++ tutorial, it's a great book about using Modern C++ features effectively.

  • [Git Repo] 30 Seconds of C++ - "A collection of C++ STL features (functions/libraries) which can be learned in 30 seconds or less**",** as stated in the README; it's a great way to learn some features of the STL with good short examples and explanations.

  • [Git Repo] C++ best practices

  • [Git Repo] Project Based Learning - "A list of programming tutorials in which learners build an application from scratch."

  • [Git Repo] Mega Project List

  • [Git Repo] Build your own X - A big list of tutorials in many different languages (including C++, of course) for building your own tools.

I'll add other users recommendations here as well as they come in the comments as long as they have a good reason to be included and feature Modern use of C++.

EDIT: I decided to not add other users' recommendations here because it would basically be a copy-paste of the comments and other readers can just check them out and figure if that's what they are looking for.


r/cpp_questions • • May 29 '20

OPEN "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off"

278 Upvotes

what are some examples of this?


r/cpp_questions • • Feb 25 '26

SOLVED Do you **really** need to free memory?

219 Upvotes

Theoretically, if your program is short lived and doesn't consume much heap memory to begin with, would it really be that bad to simply not keep track? It'll be reclaimed by the OS soon anyways, and you might see a minor amount of performance benefits, in addition to readability.

Asking for a friend of course...

Edit:

I've gotten very mixed messages. To clarify, I'm not new to the language, and I have plenty of experience managing memory on a low and high level using raw and smart pointers. The program i'm developing does not continually allocate, and always keeps references to what it has allocated, in addition to not interacting with any other software.

The problem is mostly that deleting the memory at program completion would require some logic and time that is simply redundant due to the fact that it'll be reclaimed anyways, and if I were to refactor using smart pointers i'd likely see a small amount of performance hits.

I'm probably going to use an arena allocator as suggested by some, so I appreciate the advice.

For those who insulted me and/or suggested I shouldn't be using C++ if I don't like smart pointers, I'd like to remind you that smart pointers are library features and not core to the language itself. As far as I understand, the mentality of C++ is "do whatever you want as long as you know what you're doing". I'm glad you like the easy lifetime boxes, they're genuinely useful, but i'd prefer less unnecessary abstractions.


r/cpp_questions • • Aug 08 '24

OPEN Why is cmake so hated and why not use make files?

201 Upvotes

So im pretty new to cpp around 5-6 months and ive not used cmake before only makefiles and i see alot of hate for both of them can anyone explain to me why the hate towards them and which should i pick?


r/cpp_questions • • May 15 '26

OPEN Passing LeetCode but failing HFT C++ interview rounds on obscure language trivia. Reality check/advice from C++ HFT/Quant devs needed.

195 Upvotes

Hello,

From what I understand there are two types of HFT/quant dev roles, one is python based and more closer to implementing trading strategies and the other is C++ lower level making it as fast as possible. I'm not really a maths guy and I find systems and C++ pretty interesting so I'm leaning towards the latter.

However, I think I'm hitting a wall or a mindset problem. I have interviewed with HFT/quant dev firms like HRT, Flow traders, I can pass the OA leetcode but on the next round the level of C++ they ask in the interview is a bit beyond me, they ask a bit random and obscure questions that I never seen in textbooks or some C++ trivia (questions that make me go where on earth am I supposed to know that stuff). I can't really remember the exact questions but examples are C++ features keywords I've never seen before or like what will C++ compiler do in bizarre edge cases (things I'm pretty sure that are not in textbooks I've read so far)

I know I'm pretty far behind but I wanted a reality check if this is something I have a realistic chance of getting into. I'm willing to work hard etc but I just don't have the perspective of the other side so after multiple rejections I've kind of burned out. So hoping for a more senior dev to share their thoughts. If this isn't the right subreddit or the right questions please feel free to correct me, I feel a bit lost honestly.

What I have done:

- 2 years C++11 in a non-trading related company
- 2 years Java in a trading company (regular trading not fancy)
- Can do most Leetcode mediums and some Hard
- Books read from The Definitive C++ Book Guide and List
- C++ Primer, Effective C++, Effective Modern C++, Effective STL, More Effective C++, C++ 17 The Complete Guide
- Books started but incomplete due to burnout
- C++ 20 The Complete Guide, Exceptional C++, C++ Concurrency in Action, A computer arch book (Digital Design and Computer Architecture David Harris).

What I could do (ideas I had):

- Continue studying the The Definitive C++ Book Guide and List
- Do projects like kernel bypassing, ring buffer and add to git.
- Study Computer Architecture book since I'm quite weak in it
- Make my own api for trading
- Read the green book (?) but I thought thats more for quants

Problem is, with the amount of free time I have, it will take me a loong time to finish these projects (1-2 years). And my biggest worry is that even if I finish them, I'll just be asked a really random C++ question that catches me off guard, but maybe I am jumping into worst case scenarios.

I'm honestly even considering to quit my job to focus self-studying full time as I have saved up enough but it requires some mental preparation as unemployment can also be stressful. But some recruiters said my current job is not helping me if I wanted to pursue this so I might as well quit to prepare better.

Any advice on what to do going forward would be really appreciated thank you.

Edit:
Since some concrete examples were requested I have tried to recall them as best I could, but since it was a long time ago it won't be 100%. Q what the interviewer said is what I remember and A is the response I gave.

Maybe my answers are really bad, but if I really have a blindspot any advice is appreciated.

Q: Is there a negative 0 in cpp
A: No (I wasn't sure because I knew there was a signed bit so there could be potentially +/- 0, but I thought that was odd and assumed the compiler will take care of that to avoid side effects and set it to +0 for consistency)
Q: No there is a negative 0

Q: some question if there is single producer and multiple consumer, or multiple producer and single consumer, how will this work (I don't remember)
A: I said something like 1 producer N consumer, can write to a buffer and the N consumers will take turns reading it. N producers 1 consumer I just said something like either write to a queue or consumer goes round robin.
Q: just got irritated with me (I guess I missed something basic?)

Q: Whats the point of memory alignment
A: for quicker retrivial and the archtecture is designed to handle 64bits at a time so if you are forced to use smaller sizes that will add extra processing so they will pad it.
Q: (didn't seem satisfied, maybe I missed something, maybe I am really bad at CPU arch)

Q: What are some methods to avoid using a mutex since its slow
A: Could use read-compare-write (something like used in OS)
Q: hmm, not really

Q: Is mutex handled application level or kernel or where?
A: (Ok I knew there was a mutex c++ library, but there was also a mutex in the OS/Hardware level so I wasn't sure which one so I just said OS/Hardware)
Q: No...

Q: How is the hash function for unordered_map implemented in C++
A: I... don't know, some % modulus maybe. (I never thought about looking it up, is this common knowledge? And where do I learn this? I can't even google this or I'm googling wrong)

Q: producer A consumer B, use memory barrier or atomic and where and why?

Q: what type does tie(A,B) return?


r/cpp_questions • • Apr 22 '25

OPEN Why does learning C++ seem impossible?

195 Upvotes

I am familiar with coding on high level languages such as Python and MATLAB. However, I came up with an idea for an audio compression software which requires me to create a GUI - from my research, it seems like C++ is the most capable language for my intended purpose.

I had high hopes for making this idea come true... only to realise that nothing really makes sense to me on C++. For example, to make a COMPLETELY EMPTY window requires 30 lines of code. On top of that, there are just too many random functions, parameters and headers that I feel are impossible to memorise (e.g. hInstance, wWinMain, etc, etc, etc...)

I'm just wondering how the h*ll you guys do it?? I'm aware about using different GUI libraries, but I also don't want any licensing issues should I ever want to use them commercially.

EDIT: Many thanks for your suggestions, motivation has been rebuilt for this project.


r/cpp_questions • • Sep 01 '25

META Important: Read Before Posting

189 Upvotes

Hello people,

Please read this sticky post before creating a post. It answers some frequently asked questions and provides helpful tips on learning C++ and asking questions in a way that gives you the best responses.

Frequently Asked Questions

What is the best way to learn C++?

The community recommends you to use this website: https://www.learncpp.com/ and we also have a list of recommended books here.

What is the easiest/fastest way to learn C++?

There are no shortcuts, it will take time and it's not going to be easy. Use https://www.learncpp.com/ and write code, don't just read tutorials.

What IDE should I use?

If you are on Windows, it is very strongly recommended that you install Visual Studio and use that (note: Visual Studio Code is a different program). For other OSes viable options are Clion, KDevelop, QtCreator, and XCode. Setting up Visual Studio Code involves more steps that are not well-suited for beginners, but if you want to use it, follow this post by /u/narase33 . Ultimately you should be using the one you feel the most comfortable with.

What projects should I do?

Whatever comes to your mind. If you have a specific problem at hand, tackle that. Otherwise here are some ideas for inspiration:

  • (Re)Implement some (small) programs you have already used. Linux commands like ls or wc are good examples.

  • (Re)Implement some things from the standard library, for example std::vector, to better learn how they work.

  • If you are interested in games, start with small console based games like Hangman, Wordle, etc., then progress to 2D games (reimplementing old arcade games like Asteroids, Pong, or Tetris is quite nice to do), and eventually 3D. SFML is a helpful library for (game) graphics.

  • Take a look at lists like https://github.com/codecrafters-io/build-your-own-x for inspiration on what to do.

  • Use a website like https://adventofcode.com/ to have a list of problems you can work on.

Formatting Code

Post the code in a formatted way, do not post screenshots. For small amounts of code it is preferred to put it directly in the post, if you have more than Reddit can handle or multiple files, use a website like GitHub or pastebin and then provide us with the link.

You can format code in the following ways:

For inline code like std::vector<int>, simply put backticks (`) around it.

For multiline code, it depends on whether you are using Reddit's Markdown editor or the "Fancypants Editor" from Reddit.

If you are using the markdown editor, you need to indent every code line with 4 spaces (or one tab) and have an empty line between code lines and any actual text you want before or after the code. You can trivially do this indentation by having your code in your favourite editor, selecting everything (CTRL+A), pressing tab once, then selecting everything again, and then copy paste it into Reddit.

Do not use triple backticks for marking codeblocks. While this seems to work on the new Reddit website, it does not work on the superior old.reddit.com platform, which many of the people answering questions here are using. If they can't see your code properly, it introduces unnecessary friction.

If you use the fancypants editor, simply select the codeblock formatting block (might be behind the triple dots menu) and paste your code into there, no indentation needed.

import std;

int main()
{
    std::println("This code will look correct on every platform.");
    return 0;
}

Asking Questions

If you want people to be able to help you, you need to provide them with the information necessary to do so. We do not have magic crystal balls nor can we read your mind.

Please make sure to do the following things:

  • Give your post a meaningful title, i.e. "Problem with nested for loops" instead of "I have a C++ problem".

  • Include a precise description the task you are trying to do/solve ("X doesn't work" does not help us because we don't know what you mean by "work").

  • Include the actual code in question, if possible as a minimal reproducible example if it comes from a larger project.

  • Include the full error message, do not try to shorten it. You most likely lack the experience to judge what context is relevant.

Also take a look at these guidelines on how to ask smart questions.

Other Things/Tips

  • Please use the flair function, you can mark your question as "solved" or "updated".

  • While we are happy to help you with questions that occur while you do your homework, we will not do your homework for you. Read the section above on how to properly ask questions. Homework is not there to punish you, it is there for you to learn something and giving you the solution defeats that entire point and only hurts you in the long run.

  • Don't rely on AI/LLM tools like ChatGPT for learning. They can and will make massive mistakes (especially for C++) and as a beginner you do not have the experience to accurately judge their output.


r/cpp_questions • • Oct 12 '21

OPEN I feel stupid for asking this but...how does C++ become Spotify, YouTube, Amazon, etc.

188 Upvotes

I will keep this short. I am studying C++ now as a total newbie (first semester in college). I am understanding (I mean, as best as I can at this point) the theory of how loops, if statements, etc. all work. My question is this: how does this code become a fully interactive interface like Facebook or Youtube, etc. I keep reading that all of these amazing applications or websites are made with C++.

I don't see it.

Please educate or point to what GIANT piece of knowledge I don't know yet!


r/cpp_questions • • Jun 20 '26

OPEN C++/systems side projects that actually stand out

187 Upvotes

We often see people recommend “build a compiler,” “build a database,” “write an HTTP server,” “make a Redis clone,” or “try OS-related projects” when someone wants to go beyond normal web apps and CRUD work.

But for people who want to demonstrate real C++/systems ability, what kind of project actually stands out?

I’m thinking about projects involving C++, memory management, containers, networking, databases, compilers/interpreters, operating systems, performance, reliability, or infrastructure tooling.

Ideally, I would like to build something that real people could actually use. Even if 10 people I don’t know used the project, I would consider that a huge success.

What would make a C++/systems side project look serious to experienced developers or potential employers?


r/cpp_questions • • Jun 07 '25

OPEN Should I stop avoiding const in C++?

184 Upvotes

For some reason, I rarely ever use const in my code. I didn't really get it at first and thought it wasn't worth the hassle but as I am learning more about C++ and trying to get better, I came across this bold statement:

"When used correctly, const is one of the most powerful language features in all modern programming languages because it helps you to eliminate many kinds of common programming mistakes at compile time.

For the experienced C++ programmers:

  • Do you agree with this?

  • Do you rely on const regularly in your code?

  • What are some rule of thumb you use to determine when its necessary?


r/cpp_questions • • May 22 '25

OPEN Banning the use of "auto"?

184 Upvotes

Today at work I used a map, and grabbed a value from it using:

auto iter = myMap.find("theThing")

I was informed in code review that using auto is not allowed. The alternative i guess is: std::unordered_map<std::string, myThingType>::iterator iter...

but that seems...silly?

How do people here feel about this?

I also wrote a lambda which of course cant be assigned without auto (aside from using std::function). Remains to be seen what they have to say about that.


r/cpp_questions • • Sep 13 '24

OPEN Why Linux community hates C++ so much?

175 Upvotes

It seems like they have an extreme disliking towards C++. Especially the kernel developers. Linus has even said he doesn't allow C++ in kernel just to keep C++ programmers away. Which sounds very weird because C++ seem to be used in all kinds of complicated systems, and they are fine.


r/cpp_questions • • Sep 27 '20

OPEN C++-learners: don't get bogged down in user interface

175 Upvotes

A very common question in these parts goes along the lines of "how do I read a character on the command line without the user pressing enter".

Questions like this will impede your learning. Don't let user interface questions slow you down. Worry about logic and (data-)structure and storage until you know it's time to focus on user-interface.

I recommend this is because it's all very OS-specific. That will open up a can of worms. It's also something that professionals never (almost) actually do.

When I write command-line software, I generally want it to operate on files (specified on argv) and options (specified on argv). Almost never do I want it to be reading commands from the user directly.

When you're asking questions on user-interface stuff, it's really important to know the context. Examples:

  • "I want a tool that calculates the average of a set" => then maybe just have each number be on argv, or one line per, in a file.

  • "I'm making a console tic-tac-toe" => concentrate on the logic and just deal with having to press enter. Nobody will play your game, it's ok :)

  • "I want to make a console maze-game" => use ncurses to make a more correct user interface, because at this stage maybe I actually want to learn about ncurses

  • "I want to use real graphics" => time to read about SDL, or Qt or something, depending

  • "I want to make a 3d-shooter" => time to learn about OpenGL or Vulkan.

Tldr: focus on data structures early on


r/cpp_questions • • Jul 30 '25

SOLVED Why C++ related jobs are always marked as "C/C++" jobs?

174 Upvotes

As I undersand, the gap between C and C++ is constantly growing. Then why most of C++ jobs require knowledge of C/C++ (and not "C and C++" or "C++" only)?


r/cpp_questions • • Aug 31 '25 Helpful

OPEN Are the moderators in this subreddit alive?

172 Upvotes

Can you please create a sticky thread for posts asking "how do I learn C++"?

Every week there's a post like this. These posts should be taken down because they violate the rules of this subreddit


r/cpp_questions • • Mar 29 '23

META [Meta] Could we ban/heavily discourage “Just ask ChatGPT” as answers?

167 Upvotes

I’ve seen a few answers that were “Ask ChatGPT” and it’s obvious that the people suggesting that are clueless. ChatGPT answers matter-of-factly when it’s wrong and shouldn’t be a source of answers when you don’t know the subject material well.

Straight from the horse’s mouth,

ChatGPT sometimes writes plausible-sounding but incorrect or nonsensical answers


r/cpp_questions • • Oct 12 '25

OPEN Why is the STD library so crytic to read?

165 Upvotes

How do you even manage to read this? the naming is so horrible


r/cpp_questions • • Jun 26 '26

OPEN The C++ learning advice that worries me a bit :( "Just build projects"

152 Upvotes

People who use C++ professionally seem to have very different opinions on what beginners should study first. Some swear by books, others by standards papers, and a few insist there are resources that dramatically shorten the learning curve but rarely get mentioned in beginner discussions.

I'm curious which resources changed how you think about C++, not just how to write it.


r/cpp_questions • • May 29 '26

OPEN Failing C++ interview rounds

151 Upvotes

Every company has a different style these days.

One day they ask me about fold expressions and variadics.

The other day a trading firm asked me to implement async order placement strategy.

The other day I was asked to implement shared pointer class using rule of 5.

How can I be on top of everything? I am not claiming that I know C++ at this point.

The funny thing is my solutions are 80% complete. I always miss one thing and got rejected.

How can I get to remember all these stuff at the spot? How to keep the muscle memory fresh?

I’m working on kernel optimizations for custom silicon in HPC setting.


r/cpp_questions • • Jul 26 '24

OPEN Why is C++ more popular than C for games?

147 Upvotes

Following a post on r/cpp (not mine) I wanted to hear opinions specifically for game programming:

Why is C++ the standard (at least for engines) instead of C?