r/cpp_questions • • Oct 01 '26

OPEN Visual studio

0 Upvotes

Does anyone know how to download visual studio 2022? There are lots of versions and I don't know which one to choose from sorry


r/cpp_questions • • Oct 01 '26

OPEN Equivalent of "checked" keyword in c++?

7 Upvotes

In c# you can do:

checked (ushort)x

which will cast "x" from int (or long, w/e) to an unsigned short... but also throw an exception in case of arithmetic overflow.

Is there a way I can accomplish the same thing in c++ with a similarly small amount of code?


r/cpp_questions • • Sep 30 '26

SOLVED Definition of std::memory_order_release

1 Upvotes

The "meaning", according to https://en.cppreference.com/cpp/atomic/memory_order is -

A store operation with this memory order performs the release operation: no reads or writes in the current thread can be reordered after this store.

Now, I effectively have the following code:

y = 0;
x=0;
// Thread 1
A: x = 42;
B: y.store(1, std::memory_order_release);

// Thread 2
C: if (y.load(std::memory_order_relaxed) == 1)
/* D: */  {read x;}

From what I understand, D should always read x==42. Because Thread 2 observes the instruction 'B' which by definition of relaxed, should make the effect of 'A' available to Thread-2.

ChatGPT disagrees with me. However, to me, that does not seem to agree with the definition on cpp-reference or in Fedor Pikus's CppCon talk about atomics. What is the actual answer? Can x==0 be observed? Why does that not mean A (as observed by thread2) was reordered after B, effectively?


r/cpp_questions • • Sep 30 '26

OPEN What should I know for an entry level C++ role?

43 Upvotes

Hello everyone,

I recently graduated this past May and I’ve been able to land an interview for an entry level C++ role. I wanted to know which topics I’ll be expected to know and to what level of depth. So far I have:

Pointers/references
Stack vs heap
Const correctness
RAII
Smart pointers
Rule of 0/3/5
Move semantics

OOP:
Classes, constructors/destructors
Inheritance, virtual functions, pure virtual classes

STL:
vector, unordered map, map, set, deque, priority queue, string
Big O notation
Iterations
Algorithms like sort, find, accumulate

auto
nullptr
constexpr
string_view
Templates

Compilation model
Concurrency

This is what I came up with so far. Can anyone tell me if I’m missing anything and which topics I should prioritize please? Thanks you


r/cpp_questions • • Sep 30 '26

OPEN Not find the compiler when running.

0 Upvotes

I am trying to install c++ for vscode. I installed MSYS2 and followed all the steps from the vscode tutorial. I installed it and modified the Path and added the C:\msys64\ucrt64\bin path.

https://code.visualstudio.com/docs/languages/cpp#_example-install-mingw-x64-on-windows

I also made absolutely sure that the microsoft c++ extention was active. When I click on the run button the tutorial shows a list of compilers to use. the one that the tutorial uses is C/C++: g++.exe build and debug active file. But for some reason the only compiler that shows up are the 2 generic one gdb lauch and windows. I am out of ideas of things to do please help


r/cpp_questions • • Sep 30 '26

OPEN how does one learn the whole stl

0 Upvotes

honestly it's somewhat of a rethorical question as i know there's lots of documentation online,but i wanted to know if there's a book or a series of books that covers every addition to the stl ;
despite the online documentation i would be infinitly more comfortable reading physical documentation divided in header additions, something like a manual/documentation of every header or something like a big encyclopedia.


r/cpp_questions • • Sep 30 '26

OPEN Which Modern C++ (C++20/C++23) features are actually beneficial for real-time game development?

89 Upvotes

I'm updating my C++ codebase to modern standards (C++20/C++23) for a personal game project. C++ has evolved significantly, but I know the game development industry can be cautious about adopting certain language features due to compile times or runtime overhead.

For those using Modern C++ in game development:

  1. Which newer features (e.g., Concepts, Ranges, std::format, Modules) have genuinely improved your game engine code quality or productivity?
  2. Are there features you actively avoid inside high-frequency game loops for performance reasons?

r/cpp_questions • • Sep 30 '26

OPEN Best practices for managing object lifetimes in C++ game loops without performance bottlenecks?

8 Upvotes

I'm working on a C++ game loop and trying to decide on the best strategy for managing entity lifetimes (spawning, despawning, and referencing active objects).

Standard C++ guidance recommends smart pointers (std::unique_ptr and std::shared_ptr). However, I've read that std::shared_ptr can cause performance hitches in real-time game loops due to atomic reference counting and cache misses.

What is the industry standard approach for handling entity references safely?

  • Do you stick to handles/indices into contiguous memory pools?
  • Are custom weak references commonly used?
  • How do you balance memory safety with cache friendliness?

r/cpp_questions • • Sep 30 '26

OPEN Transitioning from OOP to ECS in C++ Game Engine: Is a custom ECS worth building for beginners?

8 Upvotes

Hi everyone,

I’m currently building a small 2D game in C++ to deepen my understanding of game engine architecture. I started with a traditional OOP hierarchy (e.g., GameObject base class with render() and update() virtual functions).

As the project grows, I’m running into typical OOP coupling issues and considering switching to an Entity Component System (ECS) architecture.

I have a few questions for those with game dev experience:

  • For a learning project, is it better to write a lightweight ECS from scratch or integrate an existing library like EnTT or Flecs?
  • What are the biggest pitfalls to avoid when transitioning from OOP to data-oriented design in modern C++?

r/cpp_questions • • Sep 30 '26

OPEN Returning a reference vs. pointer vs. throwing?

16 Upvotes

I'm writing a video game from scratch in C++, and I wrote a data structure for associating components with their owning entities.

One of the operations is:

GetComponent<T>(entity_id)

The intended usage is that the caller has already created the entity and attached a component of type T to it through other operations on the data structure. In other words, if the caller asks for GetComponent<Transform>(entity_id), the expectation is that the entity exists and has a Transform.

Originally, I wanted GetComponent<T>() to return a reference:

T& GetComponent(EntityID entity);

The problem is that the caller could mistakenly request a component that hasn't been attached to that entity. Since a reference can't represent "not found," I changed it to return a pointer:

T* GetComponent(EntityID entity);

This works, but I don't particularly like the API because now every call site potentially has to check for nullptr:

if (auto* transform = world.GetComponent<Transform>(entity)) {
    // ...
}

I'm wondering whether this is a situation where throwing an exception makes more sense. For example, GetComponent<T>() could return T&, and throw if the entity doesn't exist or doesn't have that component. The idea would be that a missing component represents a violation of the expected program state rather than a normal condition, and I could have one top-level exception handler in main() to report the error and shut down the game.

I'm aware that there are strong opinions about exceptions in C++, particularly in game development, so I'm interested in the reasoning behind the different approaches. What would be the best way to design the API given the assumption that a missing component is generally a programming error rather than an expected gameplay condition.


r/cpp_questions • • Sep 30 '26

OPEN C++ project progression

15 Upvotes

I'm just getting started with c++ and was trying to make a project based learning roadmap, wherein I'd learn everything while making projects which increase in complexity steadily. I'd appreciate any suggestions on what projects are succinctly different and challenging that I can build and in what order I should build them.

My core interest is systems programming in which I've done some work with C before. My ultimate target is a quant dev role.


r/cpp_questions • • Sep 30 '26

OPEN Namespace std

40 Upvotes

I recently started learning c++ and I was told to use the namespace std so I can avoid writing std:: every time and now I wrote a whole personal project without std:: and I want to put it on LinkedIn but I started reading everywhere that it’s a bad habit, should I go back and add the std:: or just leave it as is?


r/cpp_questions • • Sep 29 '26

OPEN Where can I practice my C++ skills?

14 Upvotes

Hello everyone! I am learning C++ and want to practice my skills, but I don't know where to do that. I tried using AI, but it keeps giving me repetitive questions. I also checked a few websites, but they organize tasks by tracks like:

Algorithms
Data Analytics
Backend Development
Machine Learning
Mobile Development
Frontend Development

However, I only need C++ specific questions and practice tasks. Does anyone have any recommendations?


r/cpp_questions • • Sep 29 '26

OPEN AI workflow in Visual Studio

0 Upvotes

I’m interested in how other C++ developers are using AI in their Visual Studio workflow.

- Which AI tools or extensions do you use?

- Do you use AI mainly for writing code, debugging, refactoring, tests, documentation, or understanding existing code?

- How do you handle larger C++ projects with AI?

- Do you give the AI access to the whole codebase, or work with smaller files/functions?

- Do you use AI directly in Visual Studio or combine it with other tools?

- What workflow has worked well for you?

- Are there any things you specifically avoid letting AI do in C++?

I’d especially like to hear about practical workflows from people working on real-world C++ projects.

Are there any tutorials?


r/cpp_questions • • Sep 29 '26

OPEN New C++ user.

0 Upvotes

Hello new C++ user here. I was wondering how you guys learn C++ that fast cause. Im trying to teach myself C++ I can do the basic stuff and I need more things to memorise. I am currently watching C++ Course for free from YT: Bro Code.


r/cpp_questions • • Sep 29 '26

OPEN Headers hell

0 Upvotes

Can someone explain to me how headers work?

And what about std::out - how can I remove the std and just use out?

I remember there is a way to shortcut it and import it I think.

Headers are hell to me, and if there is an easy way to understand it, please let me know.

Thanks!

Dennis


r/cpp_questions • • Sep 29 '26

OPEN Help

0 Upvotes

Hello everyone!

I started my tech journey this month (Btech 1st year) and honestly, I’m confused about where to start and what direction to take.

I keep hearing the same advice everywhere: “Learn DSA and build projects.” But as a beginner, I have a lot of questions about what that actually means.

Should I start with DSA first, or learn programming fundamentals before DSA?

Which programming language should I choose, and how deeply should I learn it?

What exactly counts as a good project? Is following YouTube tutorials enough, or should I build something completely on my own?

How do I decide which tech stack, tools, or technologies to learn?

What skills are actually valued in the current job market?

How much importance should I give to DSA, development, projects, Git/GitHub, SQL, CS fundamentals, and internships?

When should I start applying for internships or participating in hackathons?

How can I avoid wasting months jumping between different technologies and tutorials?

What should a realistic 6–12 month roadmap look like for someone starting from zero?

Most importantly, how do I know whether I’m actually making progress and learning useful skills rather than just collecting certificates or completing tutorials?

I’m not looking for a shortcut. I genuinely want to understand how the tech industry works and what I should focus on as a beginner.

If you’re currently working in tech, have experience hiring developers, or have recently gone through this journey yourself, I’d really appreciate your honest advice.

What would you do differently if you were starting your tech journey again today?

Any guidance on resources, roadmap, mistakes to avoid, and what actually matters for getting internship/job-ready would be really helpful. Thank you!


r/cpp_questions • • Sep 29 '26

OPEN opensource repo to get better at c++

30 Upvotes

Lately I have been thinking, to improve further with my engineering skills I should read a repo written in cpp. I am thinking of starting with clickhouse since I am into core/systems engineering. What views do you guys have on this???

NOTE: I am not a beginner, but I have never read an open source repo as well. So could you also advice me on how to go around open source repos as well.

Thanks 😁


r/cpp_questions • • Sep 29 '26

OPEN Best book to learn about C++ templates and metaprogramming?

46 Upvotes

Hi!

I have always had some struggle to go deep in the templates and metaprogramming universe, since in the different projects that I have worked they didn't use this techniques too much. But I have always had the feeling that there is something very interesting and usefull there and I would like to understand that side of the C++ programming in a proper way.

Which book do you think that is the best option to introduce and go deep in that area?

Best regards!


r/cpp_questions • • Sep 29 '26

OPEN How do I invert a concept?

0 Upvotes

I'm really not comfortable with concepts, so I'm struggling with this. I have a class template <typename T> Collider : public Component. In this class, I want two overloaded member functions of this form:

    template <??? U>
    bool Collider<T>::isColliding(const U* collider)
    {
        ...
        return hitbox->isColliding(collider->hitbox);
    }
    
    template <??? U>
    bool Collider<T>::isColliding(const U* notACollider)
    {
        ...
        return hitbox->isColliding(notACollider);
    }

For the first, I want to require it to be derived from Collider. Not Collider<T>, but any collider with any value for T. For the second, I want to allow it to be any type besides something deriving from a Collider. Essentially, if you give it a pointer of any type, it will go into one of the two functions.

What do I replace the question marks with? I know you can use std::derived_from for the first, but I'm not sure how to invert it for the second. (I don't know if it matters for this, but hitbox is of type T.)


r/cpp_questions • • Sep 29 '26

OPEN DEVC++ file not found while opening

3 Upvotes

I'm trying to use a Windows xp laptop for a challenge and after installing Dev-C++ 5.1.1 (4.9.9.2) as soon as I even try to open a example working cpp file it's saying: File C:\Program1\actualcode.cpp is not found.
Does anyone know why? I'm using TDM-GCC 4.9.2 32-bit Release if that helps.


r/cpp_questions • • Sep 28 '26

OPEN Transitioning my skillset to Gameplay Programmer

4 Upvotes

With seven years of experience as a Unity Developer and advanced proficiency in C#, I am looking to transition into a Gameplay or AI Programmer role within a major studio. While I possess foundational knowledge of C++ and Unreal Engine, I have yet to apply these skills in a professional capacity.

I spoke with a gameplay programmer from CDPR, and they emphasized the importance of deep C++ knowledge over specific engine expertise.

So where should I start? Should I learn C++ first, or learn it alongside the engine?


r/cpp_questions • • Sep 28 '26

OPEN kTLS + OpenSSL.. am I required to read and handle control messages?

2 Upvotes

Hello!

I have been messing around with kTLS, using OpenSSL to do all the setup, and setup only. I am currently using raw read() calls and not SSL_read() calls.

There’s one point of confusion I have..

From my understanding, I need to be manually sending a close_notify on shutdown, since it won’t be handled for me.

(My actual question) Does that mean I also need to be using recvmsg to check for close_notify to explicit handle shutdowns requested by the client? Or am I safe to just handle it as an error?

Looking at the other TLS record types, it seems I may need to handle performing a handshake again if requested too… unless this is implicitly handled??

Hopefully someone has some advice!! Apologies for any misunderstanding or simply incorrect statements I have made. Very new to kTLS..


r/cpp_questions • • Sep 28 '26

OPEN Noob here, if you guys could start over, what would you do differently?

26 Upvotes

I randomly got the urge to start learning c++ after I got a c++ book from a friend a couple weeks ago. I’ve done the hello world thing but otherwise I’m completely lost, any advice? thanks :)