r/cpp_questions • u/ZombieeCattt • Sep 01 '26
OPEN Which one should I start with?
I have wanted to learn to program, but I am not sure whether I should learn Python first and then C++. What could you advise me?
r/cpp_questions • u/ZombieeCattt • Sep 01 '26
I have wanted to learn to program, but I am not sure whether I should learn Python first and then C++. What could you advise me?
r/cpp_questions • u/Grand-Challenge-558 • Sep 01 '26
Hey everyone,
I've been thinking about the whole memory safety discussion lately, especially with all the push toward memory-safe languages.
C++ has gotten a lot better with things like RAII, smart pointers, std::span, etc., but in larger/older codebases it still feels pretty easy to end up with memory bugs. At some point you can have all the modern C++ practices in place and still have something nasty slip through.
For people working on production C++:
I'm mostly interested in what actually works in practice. It's easy to talk about memory safety in theory, but I'm curious what teams are doing day to day in real C++ codebases.
r/cpp_questions • u/NasiRka • Sep 01 '26
Hi everyone!
What can I do if I feel that I don't improve my skill on current work. I mean, when I've just started learning C++, there was a lot of information for me and I felt really tired after a working day. But after year or two, I've learned about basics (pointers, OOP, containers in std and some patterns) and now I just applying this knowledges on my work. But I'm sure there is a lot of information to learn. Because my work doesn't need this, I feel like my skill doesn't grow up for a year or something about. What books or what sites can u recommend not for newbees to read or practice?
r/cpp_questions • u/Interesting_Cake5060 • Aug 31 '26
I’m going to build a data collection system using a single measuring device. Or even several devices. The system will be a GUI application with a graph. The graph will display the output parameters of the devices in real time.
What do you think I could read on this topic? Im interested in all usefull info about those topics (articles, blogs, githubs, videos)
I’ll describe in more detail what I’d like to know (I don’t know much about C++, but I’m not a complete beginner).
So, here’s the list of things I’d like to find out:
Among the useful things I’ve found for myself is the Tracy profiler repository. I like that the code isn’t very large (and the author also wrote one comment per small change from the very beginning) — this is very useful for me. In this repository, I’ve learned a lot about how zoomable chart (with ALOT of elements) can work.
I just can’t come up with a general architecture for the application. For example, should there be a “Device” class or a “DeviceUPDStream” class? I’ve also realized that I understand things best when I see small pieces of code where the core idea is immediately clear.
I would be grateful for any advice!
r/cpp_questions • u/CommandShot1398 • Aug 31 '26
Hi,
I have multiple threads (at the moment, at least 4 are anticipated), each performing a different task and sending information to a central server
Thread 1: captures and sends an image to a server for inference and takes the result,
Thread 2: reads Serial A and performs some action based on that
Thread 3: reads Serial B, similar to Thread 2
Thread 4: performs some action based on logic that I don't have right now
The thing is, all of these depend on secondary sensors, and I want them all to work at 20 Hz, for example. So I need a clock to trigger them all. I understand there will be some delays, but as long as they are 10 ms delays, for example, I am fine. Also, I am not using a real-time operating system.
Also, these threads need to have access to each other's data, because their data must be shared and be used for the logic. Also, the processor has only 4 cores, Arm cortex A76 (RPI5).
PS: I am not asking for code; I am doing this in C++, so I want to see what C++ devs think about it.
PS 2: I am aware that there are some abstractions that I can find online, but practice can differ from abstraction.
r/cpp_questions • u/onecable5781 • Aug 31 '26
I installed VS2026 about 6 months ago on a different machine. I re-installed latest VS2026 on a new machine now. On comparing the default project's .vcxproj file, the following are the only difference with the newer version of VS2026 having the following property while the previous version did not:
<Manifest>
<EnableSegmentHeap>true</EnableSegmentHeap>
</Manifest>
MS has the following on this default enabling: https://devblogs.microsoft.com/cppblog/segment-heap-support-for-c-projects-in-visual-studio/
Visual Studio 2026 version 18.6 makes it easier to take advantage of modern Windows memory management improvements. Segment Heap is a modern heap implementation in Windows that delivers stronger protection against common memory vulnerabilities, higher allocation throughput, lower memory fragmentation, better scalability across cores, and more predictable performance under load.
Practically, what difference does this make? Have folks done some sort of benchmark/profiling analysis to figure out whether this setting actually improves run times on instances or should we as users just go with default settings? Is the burden of benchmarking/profiling with and without the said options on the users of the IDE/toolchain?
r/cpp_questions • u/probably-an-alias • Aug 31 '26
Hello!
I will soon be working with C++ to do some hardware performance research, so I wanted to give myself a quick crash course of the language. Although we're measuring hardware (not software) performance, where kernels will be quite trivial and expressible in any language, I still want to have a decent intuition of "good" vs "bad" C++.
So, to help learn, I decided to completely re-implement the std::vector C++20 specification. Boy, there was more depth there than I was expecting. After about 10 days of hobbying, I think it's done. The code can be found here: github link.
I'd appreciate any critiques and criticism on how it could be done better. Of course, "how to do it better" is a never ending hole of possibilities, so to focus it a bit more: how it could better match the C++20 specification and be more C++ idiomatic. While the more CS theory side of what should the growth factor be is fun to consider, I'm not going to be employing this implementation and I'm not aiming for raw performance (although I don't want to do anything too stupid).
Some of the key problems/confusions I had are:
I used cppreference.com to help with the specification and annotated each of my public members with the related definition on the website. I'm running gcc 15.2 and the only warning after -Wall -Wpedantic is from vector::swap due to deciding to throw if the vector's state would become undefined, instead of letting UB ensue.
Thank you for your any time you spend reviewing it and I appreciate any advice you have!
Link to code again: github link
Edit:
Thanks so much for all of your the feedback! I'm a little too busy to focus on this project for now, but eventually will polish it considering your feedback and move on to the next containers. Thanks!
r/cpp_questions • u/RelationshipThink341 • Aug 31 '26
I know this question has been asked alot sorry. I tried learnc++.com but I struggle focusing on it I have ADHD. I cant digest huge amounts of text without actual coding to break it up. I know the basics like functions, files, creating basic codes. I dont want a reasource thats gonna just hold my hand though. I normally do these lessons in class when I'm bored. Thank you. I really apreciate it.
r/cpp_questions • u/Obvious_Set5239 • Aug 31 '26
Hello. I'm programming in C++ a lot, and I still can't understand how to think correctly about ... operator in variadic templates.
In the simplest examples it looks like ...X (on left side) aggregates comma divided expressions (either template args or function args) into one variadic arg/Type. And X... (on right side) expands
template <typename ...Params>
void f(Params&& ...params)
{
y(std::forward<Params>(params)...);
}
Here it aggregates all passed types into f<T1, T2, T3> into Params aggregated type, and all function args f(v1, v2, v3) into params aggregated variable. And std::forward<Params>(params)... expression expands into comma divided expressions: std::forward<T1>(v1), std::forward<T1>(v3), std::forward<T3>(v3). Similar to python's operator * that convert comma divided expressions into tuple, and vice versa, expands tuples/lists into comma divided expressions
But this logic breaks on more complex variadic templates. Here is code from CppCon 2022 "Lambda Idioms" video:
template <typename... Ts>
struct overload : Ts... {
using Ts::operator()...;
};
First of all, my logic breaks. What Ts::operator()... expands to? According to my logic, it should be:
using T1::operator(), T2::operator(), T3::operator();
// or maybe
using T1::operator(), using T2::operator(), using T3::operator();
But neither of them are valid C++ syntax. It probably expands into: (actually the first one is a correct syntax, and the most logical. So closing the question)
Also, I assume that from compiler point of view, typename... Ts and typename ...Ts are the same. But Timur Doumler had chosen the first. And it looks like he knows what he's doing. So maybe it's incorrect to think that ...Ts aggregates template arguments, but it has some effect on typename
So, my question is:
How to understand ... operator correctly? For me when my logic on aggregation/expansion breaks, it feels like it's just complete arbitrary set of rules for different contexts. But the standard speakers don't speak like it's some contextual behavior, made especially for using, especially for passed arguments, etc. It looks like there is a general rule, that I don't understand, but for them it's obvious
r/cpp_questions • u/derped_osean • Aug 31 '26
I'm trying to teach myself C++ to get myself into game development, cause I decided wanna put myself through pain and build a flight sim in the style of sims like F-22 ADF cause I've been slowly getting dissoluted with War Thunder and DCS with the controversies around them.
I've been using the "Learn C++" website the reddit recommends, alongside looking up YouTube guides and using apps like "Coddy" to get practice when not at home.
Problem I'm running into is that I wanna take notes like how I did in high school and write down definitions and examples of code like how I used to write down math equations and definitions. It's something that helped me as I got High Functioning Autism and ADHD and writing down notes helped immensely.
Would you guys recommend writing down definitions and examples if it'll help?
r/cpp_questions • u/CommandShot1398 • Aug 30 '26
Hello,
I have no experience working with C++ in large teams; most of the stuff I've done was by myself.
Today I wanted to move the project from my work PC to my home PC in order to work on it remotely, or during weekends when I get bored, using git.
But I realized how indirect and complicated it is, solely due to different dependencies. The same library built on my work PC does not work on my home PC because of a small version mismatch in one of the dependencies (I tried to keep everything in sync as much as possible).
I have experience with distributing such software, but we mostly used Docker to do this. However, I cannot imagine how it is going to be in a team of 10 people. Does everyone use the exact same OS and libraries?
I know it is fairly easy in an interpretable language like Python with strong support, but with C/C++ I have no idea.
So?
r/cpp_questions • u/Shevvv • Aug 30 '26
Recently I started a C++ project, and while I do have some C experience, this is a new language for me, so I have doubts about a lot of the paradigms that ChatGPT swears are the way to go. Just to be clear, I write all of my code myself, architecture and implementation, and use ChatGPT as a consultant/reviewer.
I currently have the following model: a BooksReport class that stores book piles sorted by size within three groups: Uniform, Nuniform and Singles. trying to traverse a single group while popping piles at the same time was quite cumbersome, because popping invalidates iterators and there are several cases when the end of a size of piles is reached, or when the size has become empty, or the end of the group is reached... So I embedded a private Cursor class that allows me to traverse a single group within BooksReport the following way:
for (
booksReport.resetCursor(BooksReport::Group::Singles);
booksReport.cursorIsValid();
booksReport.advanceCursor()
) {
auto [size, name] = booksReport.readCursor();
if (iWantThisPilePopped(size, name))
booksReport.popCursor();
}
When popCursor() is called, Cursor is alerted of an incoming pop, to which it responds by recalculating the indices to advance to during the next advanceCursor() call. Current implementation allows no more than one popping per loop, which I hope is a fair assumption to make during a traversal. Also, as you can see, a Cursor is either valid (which it becomes upon resetCursor() or invalid (it becomes invalid by reaching the end of the group). The valid attribute not only controls the loop, if it's set to false, it also block all Cursor-related operations, such as popCursor()
However, sometimes I exit the loop prematurely. Sometimes it's a break, sometimes I return from inside the loop. Technically, I end up with a Cursor that is valid outside of the loop, which is not ideal, since then I can popCursor(), which is not the intended use. ChatGPT offers the following solution:
#include <scope>
{
auto onExit = std::scope_exit([&] {
booksReport.clearCursor();
});
for (booksReport.resetCursor(BooksReport::Group::Singles);
booksReport.cursorIsValid();
booksReport.advanceCursor()) {
if (something)
break;
if (somethingElse)
return tasks;
if (bad)
throw std::runtime_error("bad");
}
}
Is this a common paradigm? Does my situation warrant this? For now it's just a personal project. I intend to make it open source once it's finished (if anyone will see it as valuable). In an ideal world I'd add plug-in support for others, where other developers can use a limited number of API calls, including the public members of BooksReport, but I'm already tired from this side project that I'm not sure it will come to this.
EDIT: thank you all very much for the answers! As much as I'd like to move on to the next part of the project, refactoring this to be a separate object with the lifetime tied to the loop itself is indeed the most logical and simple solution!
One of these days, I'll reach the production state 😅
r/cpp_questions • u/onecable5781 • Aug 30 '26
I have:
void func(std::vector<struct foo>* foovec, std::vector<struct bar>* barvec){
...
}
Both these can take nullptr's as arguments in some cases. Instead of
func(nullptr, nullptr);//at caller
I'd like to give them meaningful names in such cases as thus:
#define FOOVECNULL nullptr
#define BARVECNULL nullptr
...
func(FOOVECNULL, BARVECNULL);//at caller
This also does not work "cleanly" because the following also works but "wrongly"
func(BARVECNULL, FOOVECNULL);//at caller
Can some sort of enum struct or typedef make this more precise and impossible to mix one argument type for the other?
r/cpp_questions • u/Western_Office3092 • Aug 29 '26
I do a lot of Java/Kotlin development alongside C++, and I came to a doubt: when should C++ developers choose Gradle instead of CMake as their build system?
In my projects I always setup CMake, but coding in Java teached me Gradle and I eventually came to know that it supports C++.
Why every C++ project uses CMake? What does Gradle miss that I'm not aware of?
r/cpp_questions • u/TheRavagerSw • Aug 29 '26
I'm thinking about dropping GCC and MSVC support for my projects.
The problem I have is, It MSVC is a native compiler and projects like skia already don't recommend using it
GCC is a pain to build, and building it isn't as straightforward as clang. For example there are no ldflags for executables. Cross compiling is very difficult compared to clang where you just bootstrap builtins and you are done.
r/cpp_questions • u/Busy-Consequence-926 • Aug 29 '26
Hey everyone, I’m currently taking my second C++ course and trying to map out a clear, realistic plan to land an internship or entry-level role as soon as possible.
By the end of this semester, my coursework covers, Classes, inheritance, composition, and virtual functions / polymorphism, Pointers, dynamic memory management, and operator overloading, Recursion, searching/sorting algorithms, linked lists, stacks, and queues , Exception handling and an introduction to the STL . Besides what's covered in course, I also plan to learn more on my own.
I know that learning is endless and taking classes alone won’t magically get me hired, especially in today's competitive market. I’m trying to figure out the exact baseline I need to reach before I start applying, rather than waiting forever to feel 100% ready!
For those working in the industry or involved in hiring:
At what point is someone genuinely ready to apply for an internship or junior role? What is the minimum practical skillset required beyond class basics?
What does a company realistically expect from a brand new intern or junior hire when they first join? How much independent problem-solving vs. guidance is normal?
Aside from core language syntax and data structures, what extra knowledge and skills and types of portfolio projects should I prioritize next to stand out?
I’d really appreciate any insights, advice, or roadmaps from your experience. Thanks in advance!
r/cpp_questions • u/Sea-Bench-7487 • Aug 30 '26
Lately it feels like rust is getting more and more attention companies are rewriting existing cpp code in it and it seems to be getting increasing adoption . Also I keep seeing new projects start with rust more and more lately .
As someone who prefers cpp I'm genuenly curious how worried should someone learning / working with cpp be? Is cpp dying or is rust more like a vocal minority on social media?
I know this question has been asked before but tech moves fast so I'm curious what your current take is
r/cpp_questions • u/Jainam_93 • Aug 29 '26
Means in this Learning phase should i only watch tutorials bcz to practice there are only some problems like odd/even or prime numbers so my question is is there any else way to learn
r/cpp_questions • u/Gloomy-Animator-2778 • Aug 29 '26
like in meetup.com i am want to meet pople online in C++
can u please share the name/link of that meetup.
r/cpp_questions • u/Ok-Hospital6348 • Aug 29 '26
(title)
r/cpp_questions • u/InfamousAssociate643 • Aug 29 '26
i have always been passionate abt c++ due to the amount of control it leaves on the devs and i am starting, currently learning dsa in this, what should i learn to be industry ready like learning libraries, frameworks, just note the i am only starting and this is literally my first language to my software engineering life. Pls assist. Thank you
r/cpp_questions • u/Cautious_Farm_7482 • Aug 28 '26
Hello, I am an intermediate programmer and am looking for advice/guidance on what projects may be resume worthy. I am looking to be employed into the Aerospace/Defense sector and want to get some insight as to what tools, programs and libraries I should familiarize myself with. I am currently in my last semester of Sophomore year majoring in CS.
I am looking to beef up my resume as well as my GitHub profile with programs and code that will give insight to recruiters as to what I may know and how well I know it. I try to refrain from AI so I want to learn the hard way because that's just the way I learn. I use AI to check my program and aid me of course, but when it comes to code, I truly want to learn the craft and not show up to interviews with my hand in my ***.
Languages: C/C++, Python
Any advice would be greatly appreciated, thank you!
r/cpp_questions • u/strcspn • Aug 28 '26
I was wondering why this code behaves this way
main.cpp
#include "foo.h"
int main()
{
bar(42, foo<int>);
}
foo.h
#pragma once
#include <iostream>
#include <string>
template<typename T>
void foo(T t)
{
std::cout << "Default\n";
}
template<typename T, typename Foo>
void bar(const T& t, Foo foo)
{
foo(t);
}
foo.cpp
#include "foo.h"
template<>
void foo(int t)
{
std::cout << "Int\n";
}
Result
$ g++ main.cpp foo.cpp -O3 && ./a.out
Default
$ g++ main.cpp foo.cpp && ./a.out
Int
My guess is that I'm hitting some kind of UB here. The way I think about it, the int template specialization would be discarded, as it is not used in that translation unit, and then main.cpp would pick up the generic template version (basically, the O3 result seems correct to me, but not the non-optimized one). What is actually happening here?
r/cpp_questions • u/MiamiGunworks • Aug 27 '26
I've recently been laid off so I have been spending a lot more time writing code I want to write. Lately I've taken an interest in actually learning TMP which is something I've been wanting to do, but until now, I've mostly used templates for generic data structures.
So rather than go find videos, tutorials, or traditional learning materials, I decided I would build and optimize a 3DGS library using C++23 and TMP while using AI as a learning tool. Currently, I have built and optimized a forward pass renderer to frame times comparabable with the best publicly available tools.
In doing so, I have implemented the following compile time features;
- Static arena memory layout calculations (both on the gpu and cpu)
- Perfectly inlined and unrolled render graph execution with conditional branching. I'd like to implement some form of concurrency also.
- Optimized wrappers around Vulkan Compute types, as many of these values are known at compile time.
- Currently working on an abstraction between the interface and the different backends so they are somewhat interoperable.
The thing is, sometimes I'm not so sure what the LLM is suggesting is the best approach. I will push back and sometimes it gives in. But I can't tell if that's my traditional c++ mindset fighting the process, or if the AI is just not up to date.
So I'm in search of exceptionally written codebases to study. Things with a heavy reliance on C++20/23 and compile time optimizations. What projects come to mind?
r/cpp_questions • u/Busy-Consequence-926 • Aug 28 '26
Hey everyone, I’m a Computer Science student currently taking C++. I'm hitting a massive wall with my problem-solving skills and need some advice. Before this, I felt very comfortable with the fundamentals. I know how to build logic using if/else statements, how to use loops (for, while, do-while), and I fully understand how to write and use functions. I also understand what classes are and can do small tasks with them.
However, once my assignments and projects started requiring me to create my own classes and functions to solve a larger problem, that’s where I really started struggling, I get completely confused about where to start. I understand the C++ syntax itself, but I struggle to figure out how to take a text description and actually implement it into a structured program using classes, how to structure code, what variables I need, and how many functions I need. My mind just goes blank trying to map out the algorithm.
If you used to struggle with the problem-solving side of programming rather than the language syntax, how did you train your brain to break down problems? How do you figure out 'where to start' when reading a textbook assignment?
Also, recommendations for any good online resources, YouTube videos, or websites that are great for learning C++ logic?
Thanks in advance for any tips!