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 • • 4h ago

OPEN Where to start learning C++?

10 Upvotes

Hi everyone! I want to start learning C++, but I’m not sure where to begin. As my first goal, I plan to build a simple 3D viewport to understand how everything works in practice. Could you please advise on where a beginner should start?


r/cpp_questions • • 10h ago

OPEN How to learn c++ effectively and be profficient in it?

7 Upvotes

Maybe you've heard this question before, but I want to know. I've been studying c++ for a month now, and I feel like I know some of the basics, but I know that I need a different approach. I feel like I just memorize it instead of getting it. I want to learn it truly,the right way. I write a lot of code cause I know thats the best but I fall short on the thinking like a programmer part. I want to lean c++ independently,then switch to ue5 and work on a game. I would love it if you would share your methods and links to some good c++ literature. I know I'm not dumb and I know it's not easy. I am not looking for a quick solution, just the right one.


r/cpp_questions • • 23h ago

SOLVED Performance of std::vector

26 Upvotes

In the university we had to implement quicksort, the unsigned ints are stored in std::vector. I have accidentally discovered, that all algorithms, despite how students implemented them, are much faster when instead of directly accessing data from the vector like that:

arr[n]

we write:

unsigned int *a = arr.data()

and access that data by writing:

a[n]

But I can't understand why is that, in both cases it translates to one and the same: *(a + n)

The code is compiled on Clion IDE if that changes anything, no custom settings for compilation are used.

I can't directly share the algorithms for copyright reasons as they are not mine.


r/cpp_questions • • 22h ago

OPEN Is there any free interactive learning like rustlings/ziglings for cpp?

13 Upvotes

I find rustlings/ziglings to be really strong at helping me learn concepts and have it stick.


r/cpp_questions • • 17h ago

OPEN What is the best way to learn C++ for control theory implementation? Should I learn python or C++?

2 Upvotes

My background:

I'm a 5th year mechatronics engineering student that is good with matlab/simulink and is looking to expand my skills for my future career in automation/control/robotics.

I already know the basics of C++ from the course I took in college. Also, I am pretty good at 86 assembly programming. I heared that python is only used for simulations but that is what I use matlab/simulink for.


r/cpp_questions • • 1d ago

OPEN Looking for a beginner-friendly C++ book

2 Upvotes

I recently decided to dive into programming, and I picked C++ as my first language. I realize it's a tough and complex language, but I'm drawn to it because I find it really fascinating.

That said, I'm wary of getting overwhelmed by the advanced topics right from the start and ending up in a tutorial loop where I'm just stuck learning without actually creating anything.

With that in mind, I'm on the lookout for book recommendations that strike a balance, something that won’t bury me in every intricate detail, but will still help me learn enough to work on some cool and practical projects.


r/cpp_questions • • 17h ago

DISCUSSION Why C++?

0 Upvotes

C++ is a general-purpose, performance-focused programming language used across many different fields, and I'm really enjoying learning it. However, I keep seeing a lot of experienced developers criticize it heavily. Linus Torvalds famously trashed the language, even calling it a "horrible language":

"C++ is a horrible language. It's made more horrible by the fact that a lot of substandard programmers use it, to the point where it's much, much easier to generate total and utter crap with it. Quite frankly, even if the choice of C were to do nothing but keep the C++ programmers out, that in itself would be a huge reason to use C."

He basically called C++ developers idiots. Even though he made this comment years ago in 2007, to be exact, it's starting to make me doubt my choice. And it's not just Linus; other tech pioneers and plenty of people on Reddit talk negatively about C++ as well. Different people have different critiques about the language claims such as, it's memory unsafe, violates clean language design principles, and more.

So, are these critiques mostly aimed at older versions of C++, and did modern C++ (C++11 and beyond) actually fix these issues? What are your thoughts?


r/cpp_questions • • 2d ago

OPEN Which book is the best for learning systems programming and low level in Modern C++ (17/20)

32 Upvotes

I have done some systems programming in C and C-style C++ with some operator overloading. But I want to learn Modern C++ (17/20) too and keep on doing systems programming along with low-level dev, which books do you recommend for me to follow?


r/cpp_questions • • 2d ago

SOLVED Confused between using learncpp or a book ? if book reccommed me the best ones

3 Upvotes

I have studied basic python in my high school , i have some foding knowledge and i know c till pointers , should i ue learncpp for learning cpp or any book , if bookplease give me the best ones


r/cpp_questions • • 2d ago

OPEN Bluetooth pairing

0 Upvotes

Guys am trying to have a Bluetooth manager(connect multiple device on one Bluetooth) work using cpp the thing is am not that good at cpp any recommendations. I tried using ai for advice but holy sh*t it's making it worse


r/cpp_questions • • 2d ago

OPEN Is this possible?

9 Upvotes

I’m working on a game engine as a way to learn C++ and CMake. I’m attempting to create an editor for my engine, and I want to use ImGui. I’ve been going back and forth about whether I want ImGui on the engine or editor, but I think I want it on the engine because the engine owns the main loop, so it can just do the imgui frame lifecycle stuff. Also, if I ever decide to learn Vulkan and switch to it (unlikely), I don’t think I’d need to update the editor.

The problem with putting it on the engine is that the game will now have ImGui and this code running each frame, not actually doing anything. I’m sure this has little to no impact on performance, but I feel like it’s unnecessary?

Anyways, I’m wondering if it’s possible to make it so that if I run the editor, then the ImGui code runs otherwise, it’s stripped out. I know there is conditional compilation I just don’t know if that is something that can be done in this scenario?


r/cpp_questions • • 3d ago

OPEN Is C++ worth it?

48 Upvotes

I've been wondering whether learning C++ would be worth it. I'm really interested in hardware design. I've even built my own CPU in Logisim, and now I'm looking to get into parallel programming and GPU computing.

I also enjoy programming highly efficient simulations and machine learning projects purely out of curiosity. Would C++ be a good investment for these interests, or would I be better off focusing on other languages?


r/cpp_questions • • 2d ago

OPEN Is C++ used outside of Unreal engine?

0 Upvotes

I feel like this is a really dumb question but I have been wondering if C++ is only used in game engines. I know godot also supports C++, but I saw some random comments mention that other companies like robotics or just other tech companies in general use C++ and now I'm really curious.

I'm currently in my first year of uni for game dev and we're learning blueprints atm, but I've been thinking of learning C++ in my spare time. After hearing about ue6 and verse, I got kinda nervous about the future of both blueprints and C++. I imagine a lot of companies will continue to use ue5, but if other industries use C++ it gives me a lot more opportunities, especially if I spend my next 3 years of uni being really productive with code and whatnot.

Thank youuu

Edit: Ok thank you everyone, I had no clue it's basically used for everything. All of your responses definitely make me feel a lot better regarding the opportunities I'll have when I graduate, as that was the main concern..

I'll get a head start on learning C++, very excited!!


r/cpp_questions • • 4d ago

OPEN how do header files work?

17 Upvotes

been trying to learn c++ recently, but ive been caught on header files. I have been told that they declare functions/variables, and including them basically makes the compiler copy/paste it above the code. however, i still dont quite understand it. How does the compiler know what to run in a function declared in a header file if there's no definition? My intuition tells me i need a .h file and a .cpp file along with the main file in order for it to work but i still dont understand how that would let the code run.

would i declare a function in the header file and then write the inside of the function in the cpp file?

like with the following code

//in blah.h

int sum(int a);

*********************

//in script.cpp

#include blah.h

int sum(int a)

{

return a+1;

}

******************

//in main.cpp

#include blah.h

#include <iostream>

int main()

{

std::cout << sum(1);

return 0;

}

*****************

would that compile?????????

and even so, how does the compiler read that?????

does it like know the declaration then search for the definition????


r/cpp_questions • • 3d ago

OPEN Rendering text through ImGui?

2 Upvotes

I'm hoping to get a basic repl running with ImGui, OpenGL, and GLFW. I'm comfortable with GLfW and OpenGL rendering but not the ImGui portion.

My question is, can I use the OpenGL context and the GLFW window and then get basic text editing functionality with just ImGui? No opengl buffers, no custom shaders. I think the opengl context needs a default vertex and fragment shader to function but I'm looking to keep that very minimal and handle basic repl input and text rendering between imgui::begin() and imgui::end(). A basic per keypress render loop where each GLFW key event updates a string and then ImGui renders a new frame for the window. I haven't worked with ImGui before. Do you think this is possible?


r/cpp_questions • • 4d ago

OPEN Learning to write video games from scratch

8 Upvotes

Hello everyone! This year I took a course on game development programming. I learnt alot of cpp basics, and eventually went on to write:

  • a couple classes from the Standard Templated Library
  • some trees and sorting algorithms
  • matrix and vector types for a raylib game (math as well)
  • a small raylib game with tanks
  • some enemy ai stuff such as pathfinding algorithims, a state machine & a behavior tree

eventually the course went into more Unreal Engine territory and I feel that as a C++ dev, it leaves alot to be desired. There's heeps I need to learn, and I want to also break it down to the basics before I go and write some more complex and large programs, but my end goal is write games basically from scratch, with the use of maybe some libraries at the very best. I do not enjoy or like the smell of game engines, since I do not know what is really happening underneath. I am trying to create a curriculum for myself for this coming year, of things to study on my own. Some ideas for what I want to do this year are: (in no particular order)

  • eventually create a 3D rendering engine (and understand the maths that makes it all work)
  • eventually write a minecraft clone (for learning purposes)
  • make some sort of RPG based heavily on this new game coming out on steam UNDERKEEP
  • and eventually.. become a C++ wise guy and make sellable games from scratch

does anyone have any suggestions, books, tutorials/guides, things to try and write, or communities to join, any suggestions at all? Thankyou!


r/cpp_questions • • 4d ago

OPEN Going to Study OOPS in C++ From Tommorow, any advice???

5 Upvotes

Just Completed basics of C++ Programming language like :- \*Syntex

\*Logical Operators

\*Conditional Statements

\*Loops

\*Some of data Structures like :- 1.Arrays , 2.Vectors , 3.Stack , 4.Queue

Now going to Study OOPS from tomorrow, Seeking for advices Based on Practical Industry Experience.

It will be a lot of help


r/cpp_questions • • 4d ago

OPEN cpp class vs namespace

3 Upvotes

in my personal opinion, at least half of the purpose of using nested namespace is to manage visibility, the rust's mod allows it but cpp's namespace does not, only class allows it( the public and private)

is using classes with static functions inside everywhere instead of using namespace an already existing way to use the "namespace" in a way that i can more conveniently manage visibility?


r/cpp_questions • • 5d ago

OPEN C++ and Data structure

3 Upvotes

Which topics of C++ required for Data Structure??


r/cpp_questions • • 5d ago

SOLVED How do you implement/create tests correctly ?

4 Upvotes

Hi !

I have been working on a personal project for 9 month which allowed me to learn a lot but I’m going through a somewhat more challenging phase as I explore unit testing due to CMake configuration and project architecture.

I choose Google Test but my questions are not very specific to this framework. Like I said, I already have a lot of code and I want to use tests cause it seems very useful to create a solid program.

Moreover, my project is a library + an executable so this complicates things in the linkage for example.

How do you manage tests ?

What do you test (because the test exec doesn't have access to private method or private include of a library) ?

About CMake and Google Test, are there any things I should watch out for ? How properly use folders to organize that ?

Do you have any recommendations on where I should look to learn more on the good habit with that ?

I can give you more information if you need, thanks for your time !


r/cpp_questions • • 5d ago

OPEN Reccommend Book

0 Upvotes

finding a book that teaches from basic intermediate to advanced c++ and also have projects in it.


r/cpp_questions • • 6d ago

OPEN I want to be a professional C++ systems programmer, but my university and its internship companies are obsessed with the apps programming

96 Upvotes

This is depressing; C++ is a language I love for the freedom it gives the developer, And my university is obsessed with high-level programming, Python, Javascript, and they even consider PHP to be cutting-edge technology!.

I don't want to simply do a job I don't love and do low-level work in my free time; I want to incorporate C++ into my future work, and don't come at me with "then look for a remote job" we all know that's not an option these days.

Even so, robotics is one of the majors at my university, but they only teach V+ and Linear Algebra; I suppose that's the lowest level I can reach in a work environment.

Have you ever been in a similar situation? How did you cope? Any advice?.


r/cpp_questions • • 5d ago

OPEN Book on cpp

0 Upvotes

So i was looking on amazon for a book about cpp and i found this https://a.co/d/06VJe0OR and was planning to buy it. The people that have read and used it is it good for learning the language?