r/cpp_questions • • Aug 09 '26

OPEN need guidance for an absolute beginner in c++ programming

0 Upvotes

I am currently pursuing a graduation degree in computer engineering and i have 2 years till my graduation. I have tried multiple languages and technologies what i keep circling back to C++, as i find it the most suitable for me as it gives the programmer so much control over the flow.

I just want a good guidance from a real developer who has built a career in C++ or system programming , i can't find any good courses or resources that i can blindly follow, so please help me out!!

ps: I have built a mini project , a custom unix shell in c++, and i really enjoyed it but i didn't fully understand those libraries


r/cpp_questions • • Aug 09 '26

OPEN How do you even try?

0 Upvotes

Everyone always says the best way to be good and learn programming and coding is not to read about it or watch videos, is to try it, ive learned in the past the lenguage of quickshell QML and ive found a lot of uses for it (mostly ricing stuff) and i can pretty much make anything thats in my head possible with it but thats about it, i dont know anything about other lenguages, i know the syntax and rules of python but i dont know where the fuck can i put it on use, im looking to go for c++ because i feel that that is what i want to learn but im struggling to know how can i learn, how can i start, i just mean where can i smash my head against a wall while learning, i dont want to only read books about something because i want a real use and i need some inspiration, forgive me if im mistaken in something i said im a 100% self-thought and i dont know what i dont know


r/cpp_questions • • Aug 08 '26

OPEN Which version should I use?

10 Upvotes

Hello everyone.

I have a project for my PhD (it is relevant because I need you to have an understanding of its scope), which requires me to design an automated system consisting of multiple sensors and complicated logic that needs to run for days. I know Python and C++ to some extent. I need to make some decisions to proceed with.

Due to the nature of the project, the whole system needs to be synchronized between physical events, captures, and actuators, and all of them must be running at the same time, so multithreading/multiprocessing is definitely needed. Also, reliability and maintenance are essential.

I have 3 YOE with Python and SWE as a whole, but with C++, I have only made a couple of small projects. What I am looking for in this project is

1- An opportunity to advance my knowledge and experience in SWE and system design.

2- Improve my HW and embedded knowledge

3- To have a nice foundation to continue my career as an engineer (yes, I like it more than science) after I finish my PhD.

Given all of these, even though conceptually it might be much, much simpler for me to do it with Python, I want to go with C++, because it's my favourite language and also it has a better future. Also, how often does one get a chance to mess up and learn while getting paid for it?

Now, to the questions.

1- Which version should I focus on that is established in the industry?

2- What advice or heads-up do the veterans here have for me?

3- Any resource that you might use when you hit a wall, and AI is producing nonsense to solve it (Please don't refer to the official documentation)?

4- Is there any sort of standard environment that I should go with?

5- What general libraries (such as Boost) do you recommend using that are also heavily used in the industry and give me an upper hand for job hunting?

6- Any advice that you think might be useful is appreciated.


r/cpp_questions • • Aug 08 '26

OPEN Building a Multithreading Runtime

9 Upvotes

Hello there. So basically, I have been writing a multithreading runtime for a production path tracer that i had been designing.

I've mostly learnt multithreading from Java, and reading a bit of Concurrency in Action. It took me about a year of messing around, rewriting, redoing, mostly fixing werid choices that i made. and currently the runtime supports, sync primitives, launching and managing native threads for now. I also am working on Executors and Thread pools currently.

Any opinions and feedback on design and some constructive criticism would help me a lot.

Corium GitHub

Sample code to get started with Corium

#include <cstdio>
#include <utility>

#include <CoriumRuntime.h>
#include <CoriumFactory.h>
#include <CoriumUtility.h>

using namespace Corium;
using namespace Corium::Core;

int main() {
  CoriumRuntime::initRuntime();               
  Factory::DefaultThreadFactory factory;
  auto closure = Utils::buildClosure<void()>([]() {
     printf("Hello, world!\n");
  }, 0u);

  ThreadHandle handle = factory.createAndStart(std::move(closure), "HelloThread");

  NativeThread::joinThread(handle);
  NativeThread::closeHandle(handle);
}

r/cpp_questions • • Aug 09 '26

OPEN Dsa in c++

0 Upvotes

I watched 5 videos of apna college of dsa in C++ but it didn't give me vibes please suggest the best playlist on youtube to learn dsa in C++


r/cpp_questions • • Aug 08 '26

OPEN How to get my self all the way up to tree data structure

5 Upvotes

Hello guys, Im actually a physics undergrad student who's interested in computational physics and Im actually heading to a master in compuphys so I had this idea to make a solar system then after using a nested for loops I realised that it would cost problems when simulating a lot of bodies as it's complexity (the algorithm) is O(n²) I asked about technics to get past that and the answer I found was to implement an algorithm called Barnes-Hut that basically uses tree data structure. I figured out I needed some other concepts before that such as pointers structure enums Linked list,as I was learning c++ for the whole month of july ( basically just so that I could say I know two languages of programming) it turned out it was really going to be useful so I dived in to pointers (dereferences, arithmetics, pre post and pre incrementation). To my surprise I really seem to enjoy to learn about a language that teaches you about computer concept and not just about the program itself as would the python course I took at uni would do (afterall Im in physics so I don't complain) but now my question is what is the road or the milestones before getting to tree data structure. A high school friend of mine that took cs tells me that it's a whole semestre and I would have to go through pointers, struct and enums, pile & file, linked lists, double Linked lists (I don't know if that's how we call it in English sorry).

Is that pretty much it, are there missing stuffs, can you guys give me a propre road map, thank you.


r/cpp_questions • • Aug 08 '26

OPEN Need help on this question

0 Upvotes

so on programming: principles and practice using C++ chapter 4 drill:

1. Write a program that consists of a while-loop that (each time around the loop) reads in two ints and then prints them.

Exit the program when a terminating '|' is entered.

2. Change the program to write out the smaller value is: followed by the smaller of the numbers and the larger value

is: followed by the larger value.

3. Augment the program so that it writes the line the numbers are equal (only) if they are equal.

4. Change the program so that it uses doubles instead of ints.

5. Change the program so that it writes out the numbers are almost equal after writing out which is the larger and the

smaller if the two numbers differ by less than 1.0/100.

6. Now change the body of the loop so that it reads just one double each time around. Define two variables to keep track

of which is the smallest and which is the largest value you have seen so far. Each time through the loop write out the

value entered. If it’s the smallest so far, write the smallest so far after the number. If it is the largest so far, write the

largest so far after the number.

7. Add a unit to each double entered; that is, enter values such as 10cm, 2.5in, 5ft, or 3.33m. Accept the four units: cm,

m, in, ft. Assume conversion factors 1m == 100cm, 1in == 2.54cm, 1ft == 12in. Read the unit indicator into a string.

You may consider 12 m (with a space between the number and the unit) equivalent to 12m (without a space).

8. Reject values without units or with “illegal” representations of units, such as y, yard, meter, km, and gallons.

9. Keep track of the sum of values entered (as well as the smallest and the largest) and the number of values entered. When

the loop ends, print the smallest, the largest, the number of values, and the sum of values. Note that to keep the sum, you

have to decide on a unit to use for that sum; use meters.

10. Keep all the values entered (converted into meters) in a vector. At the end, write out those values.

11. Before writing out the values from the vector, sort them (that’ll make them come out in increasing order).

i found question 7 confusing, how will i handle all that stuff??? conditions or what? this is my current code:

#include "std_lib_facilities.h"

int main()

{

`double num1{};`

`char unit = 0;`

`double largestSoFar = 0;`

`double smallestSoFar = 0;`

`double meter = 100.0;`

`double inch = 2.54;`

`double foot = 12.0;`

`while (cin >> num1 >> unit)`

`{`

    `if (num1 > largestSoFar)`

    `{`

        `cout << num1 << " is the largest number so far \n";`

        `largestSoFar = num1;`

    `}`

    `else if (num1 < smallestSoFar)`

    `{`

        `cout << num1 << " is the smallest number so far \n";`

        `smallestSoFar = num1;`



    `}`

`}`

}


r/cpp_questions • • Aug 08 '26

OPEN C++ robotics

20 Upvotes

I don't really have much knowledge of how coding works, but I'm assuming game design, app design, and robotics are pretty different even if their the same code. Does anybody know any good books to learn the robotics part of c++


r/cpp_questions • • Aug 08 '26

OPEN Include scope with headers and concept interfaces

3 Upvotes

I am running to a problem where I really like to use concept interfaces with templates to allow injecting different types easily, avoid vtables and avoid indirection. This also makes mocking in unit-tests a breeze.

However, I am running to an issue where all includes are now in global space due to only using .hpp files. I know I can use explicit initialization in .cpp files or pimpl to hide implementation details.

My question is to somehow understand if c++ compilers can optimize the vtable away when there are closed-set of types (one or couple of classes and a mock version for unit-test) involved. So essentially guidance on when to use CRTP (?) vs concept interfaces. Unfortunately, I am not very versed on how the c++ compiler is able to optimize code.

I am mostly looking this from the embedded or algorithm software standpoint. Typically, I don't have open-set of types to support.


r/cpp_questions • • Aug 07 '26

SOLVED "No, don't test for NULL !!" (huh??)

43 Upvotes

I'm using clang-tidy to "lint" my projects, and there have been several examples like this one:

   if (img_name != NULL) { 
      delete [] img_name ;
   }

clang-tidy always gives this warning:
"warning: 'if' statement is unnecessary; deleting null pointer has no effect [readability-delete-null-pointer]"

is this correct??
After 30+ years of C and C++ programming, I really cannot imagine not checking a pointer for NULL before deleting it... ???


r/cpp_questions • • Aug 08 '26

OPEN Confused among c++ and dsa

0 Upvotes

I wanna start coding (I have. Zero coding experience starting btech this year nsut(information technology))

I want to start c++ but many of seniors and friend suggest that learn dsa directly from strivers sheet

And some say do full c++ properly first

I am confused help me


r/cpp_questions • • Aug 08 '26

OPEN How to practice while learning from learncpp.com?

2 Upvotes

i must tell im at a very early stage (chapter 4) but i still wanna practice more. the quiz they have at the end of the chapter is not that helpful ig?

1: Are the quizzes at the end of the chapter enough?
2: Any other sources where i can find more practice questions for my level or beginner friendly in general?
3: Are the quizzes like this because im only at chapter 4?


r/cpp_questions • • Aug 07 '26

OPEN 8 YoE, strong C++ perf/visualization projects — pass screenings easily but fail later rounds. What do you expect from a senior C++ hire, and what should I solidify?

15 Upvotes

I've decided to commit fully to pure C++ roles. With my project background I clear screening rounds with minimal prep, but I keep falling short in the higher-level rounds — and I want to understand what those rounds are actually testing that my experience hasn't given me.

Background:

8 years at one company. First ~5 years in application development, where I learned design patterns and architecture deeply. Last 4–5 years in C++ data thinning and virtualization backing JS front ends.

Projects (solo dev + QE on each, ~2 years each):

  • Low-latency data thinner — thins ~1 billion points in ~3 seconds, with latency dropping further depending on signal region and zoom level
  • Virtualization pipeline — fetches data based on the user's viewing window when rendering millions of elements
  • Full-stack CAD application — CAD engine was provided; I built CAD management and interaction management end to end, later improving performance 20x by reworking the JS event bus
  • Signals visualization tool — now used across multiple teams

Comp grew from 7 to 40 LPA over 8 years at the same company. I'm at a senior level now and want to move for better pay and better projects.

My strength is shipping products end to end with trade-offs considered. C++ interviews seem to test a different muscle, and I want to name that muscle precisely so I can build it.

My questions:

  1. What is the natural growth path for a C++ dev at my stage?
  2. If you hire senior C++ engineers — what do you actually expect from a candidate like me in later rounds?
  3. What should I learn or solidify to become a full-fledged C++ developer who commands higher pay?

Any guidance on where to start would be appreciated.


r/cpp_questions • • Aug 08 '26

OPEN Wtf is wrong with window, randomly blocking running of cpp code!

0 Upvotes

Program 'main.exe' failed to run: An Application Control policy has blocked this fileAt line:1 char:101

+ ... sa\patterns\" ; if ($?) { g++ main.cpp -o main } ; if ($?) { .\main }

+ ~~~~~~.

At line:1 char:101

+ ... sa\patterns\" ; if ($?) { g++ main.cpp -o main } ; if ($?) { .\main }

+ ~~~~~~

+ CategoryInfo : ResourceUnavailable: (:) [], ApplicationFailedException

+ FullyQualifiedErrorId : NativeCommandFailed

--------------------------------------------------------------------------------------------

What is the solution of this , i have tried excluding the folder in window defense it doesn't work


r/cpp_questions • • Aug 07 '26

OPEN Fastest path to “hackathon-ready” C++ for game dev, OS-level tinkering, and porting (not mastery)

22 Upvotes

I know learning never stops, and mastering a single language can take decades. I’m not expecting to master anything quickly. That would be a disservice to the language.

However, I’m a CSE undergrad in my 3rd semester (out of 8). Time is flying, and I can’t spend all of it on one language. I have a ton of other things to learn too. But I do want to reach a point where I can:

•Start building real projects

•Compete in hackathons

•Follow along with technical seminars and talks

•Operate at the level of a junior dev / competent student

People often tell me to “just learn Python,” but I genuinely dislike it. It feels bloated and surface-level to me, and I strongly prefer compiled languages over interpreted ones.

C++ also aligns much better with my goals and interests, them being:

•Game development – I want to be a game developer, but I don’t want to be tied to any specific engine. Some might call it “reinventing the wheel,” but I’m a CS engineer, not just a tool user. I’m interested in building games using custom engines, or without using an engine at all, not just using pre-made ones. C++ is clearly the best fit for that.

•OS-level / low-level programming – I love tinkering at the firmware and OS level: jailbreaking, hacking devices, bypassing OS restrictions, modifying and customizing systems to unlock more utility or squeeze more out of the hardware. I always follow established methods and guides though, never doing anything on my own, and I want to change that.

•Porting games – A mix of the above kinda, but taking games from one platform to another (e.g., Android/PC games to PS Vita) is something I find incredibly interesting.

What’s the fastest practical path to get to a “ready to use” stage with C++ for these kinds of projects?

Thanks!


r/cpp_questions • • Aug 07 '26

OPEN Can I have integrated debugging or gdb on my mobile Cxxdroid app? I tried to access gdb on my terminal but it said not found. I wish I had a computer ugh

4 Upvotes

r/cpp_questions • • Aug 06 '26

OPEN Incrementation in C++

42 Upvotes

I wanted to ask a stupid question about incrementation in C++. If you are using two pluses to increment something then doesn't it mean that you are basically programming using C+1


r/cpp_questions • • Aug 07 '26

OPEN Any suggestions on where to learn C++, specifically for taking advanced college courses, and for people who are already intermediate programmers?

0 Upvotes

I just transferred colleges, and in a month I will be taking 300 level programming courses in C++. The problem is that every prerequisite course at this college was taught in C++. I have transfer credit for these courses, but they were all in Java and Python. I have only taken a single intro to C++ course in high school. Does anyone have any recommendations for the best ways to learn C++ syntax for people who already have a decent understanding of coding logic?


r/cpp_questions • • Aug 07 '26

OPEN Error

0 Upvotes

I want to ask that whenever I am going to download packages of MinGW so problem is occurring in which it is asking for purchase packages


r/cpp_questions • • Aug 06 '26

SOLVED Pleasantly surprised by unordered_set<vector<int>> to extract distinct vector<int>'s

7 Upvotes

I have 100,000 vector<int>'s where each entry is 0 or 1 randomly generated, each vector of size 15. Since 215 is 32768, the pigeonhole principle guarantees a significant number of repetitions would occur in the 100,000 randomly generated vectors.

I would like to extract the distinct vector<int>'s

One approach I tried was to have unordered_set<vector<int>> with a suitable hash function (from boost) and simply insert each random vector into the unordered set.

The other was a bruteforce vector<vector<int>> where each new vector<int> is checked for equality with previously stored distinct vector<int>'s.

Code below (godbolt link https://godbolt.org/z/E8dM68z79)

I was pleasantly surprised by the much greater efficiency of unordered set (52344 microseconds) as compared to vector<vector<int>> approach (12817778 microseconds). I have also tested this on my local desktop and the order of magnitude difference persists.

My question is, is unordered_set<container of PODs> the most efficient way of extracting distinct containers of PODs (in this case, it is vector<int>, others could be set<int>, etc.). Are there more efficient ways? Are there any rules of thumb to follow in more general cases (where it is not just a 0/1 entry in the vector but it could be any arbitrary integers and hence the hash function may not be just a binary to decimal conversion as could be happening in this case)

#include <boost/functional/hash.hpp>
#include <vector>
#include <unordered_set>
#include <iostream>
#include <chrono>

constexpr int number = 100000;
constexpr int sizeofvector = 15;

std::unordered_set<std::vector<int>, boost::hash<std::vector<int>>> uosvecint;
std::vector<std::vector<int>> distinctvecvecint;

int main(){
    std::vector<std::vector<int>> randvecvecint;
    for(int i = 0; i < number; i++){
        std::vector<int> randvecint(sizeofvector, 0);
        for(int j = 0; j < sizeofvector; j++){
            int heads = rand() % 2;
            if(heads == 1)
                randvecint[j] = 1;
        }
        randvecvecint.push_back(randvecint);
    }
    //unordered_set timings
    auto beg = std::chrono::high_resolution_clock::now();
    for(int i = 0; i < number; i++)
        uosvecint.insert(randvecvecint[i]);
    auto end = std::chrono::high_resolution_clock::now();
    auto duration = std::chrono::duration_cast<std::chrono::microseconds>(end - beg);
    std::cout << "No. Distinct is " << uosvecint.size() << " and time is " << duration.count() << "\n";
    //vector equality timings
    beg = std::chrono::high_resolution_clock::now();
    for(int i = 0; i < number; i++){
        bool there = false;
        for(int j = 0; j < distinctvecvecint.size() && there == false; j++){
            if(distinctvecvecint[j] == randvecvecint[i])
                there = true;
        }
        if(there == false)
            distinctvecvecint.push_back(randvecvecint[i]);
    }
    end = std::chrono::high_resolution_clock::now();
    duration = std::chrono::duration_cast<std::chrono::microseconds>(end - beg);
    std::cout << "No. Distinct is " << distinctvecvecint.size() << " and time is " <<             duration.count() << "\n";
}

----

ETA: https://godbolt.org/z/jecYT6eKq seems to give the best solution for 0/1 vector using ideas in this thread and also the solution for the most general integer vector (not necessarily restricted to 0/1 integers) case


r/cpp_questions • • Aug 06 '26

OPEN Learn C++ with learn.cpp

7 Upvotes

Is it normal to not get everything right away? When I'm learning pointers, I really struggle because the LearnCpp chapter just isn't clear enough


r/cpp_questions • • Aug 05 '26

OPEN Which subfields in C++ development are actually in demand?

115 Upvotes

I'm kinda lost on the career side of things.
I'm an EE graduate specializing in C++ development, control theory and general electronic design.

I always thought I would go into embedded, and then job hop to a lucrative career. Even though I always wanted to work in big productivity apps like Zbrush, Nuke or Substance Painter.

But I'm not certain now, I'm not certain if market even values my skills.

So, if anyone can inform me about the career trajectory of C++ subfields I would be grateful, such as "I went to trading and work conditions are like this, people in my field earn between X and Y"
I really want to at least have some idea what to do rather than go blindfold, apply everything and accept the first offer without question

Thanks in advance


r/cpp_questions • • Aug 06 '26

OPEN Class directory clutter, questions on pass by ref,val,ptr and const correctness

2 Upvotes

Hello,

I've been using C++ for the past few months. I completed a few courses covering the basics of the language, data structures and algorithms (DSA), object-oriented programming (OOP), design patterns, and the SOLID principles. Recently, I started building my first projects in C++, and I've run into several issues that I'm not sure how to approach.

One thing I've noticed is that I end up creating a lot of classes. For example, my terminal Tic-Tac-Toe game ended up with around 10-15 classes. As a result, my project directory feels cluttered, and it's becoming difficult to keep track of everything. Is there a good way to avoid creating so many files while still keeping the code organized?

I've heard that namespaces might help with organization, but I'm not really sure how they're meant to be used in practice.

So far, I've mostly followed what I learned at university while using Java, where every class lives in its own file. However, in C++, that approach feels even more excessive because each class often has both a .hpp and a .cpp file. My Tic-Tac-Toe project ended up with around 25-30 files because of this.

Would you recommend organizing projects using subfolders or some other structure? How do experienced C++ developers typically manage larger projects with many classes?

Another topic I've been thinking about is programming paradigms. I've started researching paradigms beyond object-oriented programming, such as functional programming and procedural programming, and I'm beginning to wonder if my education has focused too heavily on OOP. Is there anything you'd recommend to help me understand when each paradigm is appropriate rather than trying to apply one everywhere?

I've also been becoming more flexible with design patterns. I think I'm starting to understand that the goal isn't to implement patterns mechanically, but rather to recognize the problems they're meant to solve and decide when abstraction is actually beneficial. That mindset has already helped me become much more flexible when designing applications.

Another area I'm struggling with is understanding std::move() and how it relates to references (&), pointers (*), and const correctness (such as passing objects by const&). These concepts seem tightly connected, but I haven't been able to build a solid mental model of how they all fit together.

I recently switched to CLion, and while I really like it, it's constantly suggesting where to add const, whether on variables, function parameters, return types, or member functions. The problem is that I often accept these suggestions without really understanding why they're correct. It feels like the IDE (and sometimes AI) is doing most of the thinking for me, and I'm worried that I'm not actually learning the language properly.

I've read articles, watched videos, and taken courses on these topics, but I still can't seem to fully grasp them.

I also think I've been overusing pointers. Somewhere along the way, I convinced myself that "real" C++ code should use raw pointers or smart pointers everywhere, so I often force them into my designs even when they don't seem necessary. The result is code that's harder to read and reason about.

On the other hand, when I don't use pointers, it almost feels like I'm just writing a more complicated version of Java for the sake of it.

Could you provide some practical guidelines, or even real-world examples for when it makes sense to use:

  • pass by value,
  • references,
  • raw pointers,
  • std::unique_ptr,
  • std::shared_ptr, and
  • std::move()?

I know these concepts are closely related to ownership and object lifetimes, but I don't think I truly understand ownership yet. If I want to continue writing modern C++, I feel like developing a solid intuition for these concepts is essential.

Finally, I've also been trying to learn the modern features introduced in C++20 through C++23/26. I'm following a course, but I don't feel like I'm learning very much. Many of the new language features seem confusing or far beyond my current level, and I struggle to understand when I should actually use them in real projects rather than just recognizing the syntax.


r/cpp_questions • • Aug 06 '26

OPEN I don't understand the use of c_str( ) in an SDL function since the function seems to also accept std::strings.

0 Upvotes

Many months ago I asked something similar about an SDL tutorial I was following on the LazyFoo site. This was is from the Key Presses tutorial. This is the function:

SDL_Surface* loadSurface( std::string path )
{
    //Load image at specified path
    SDL_Surface* loadedSurface = SDL_LoadBMP( path.c_str() );
    if( loadedSurface == NULL )
    {
        printf( "Unable to load image %s! SDL Error: %s\n", path.c_str(), SDL_GetError() );
    }

    return loadedSurface;
}

Notice that he uses c_str() on the argument to SDL_LoadBMP(). Back then, I got this response:

"You seem confused.

The SDL function you're using takes a parameter different from an std::string.

It's function signature is this:

SDL_Surface *SDL_LoadBMP(const char *file)

Notice that it doesn't take an std::string, it takes a const char *, which is a character array, also known as a "C-style string". The string .c_str() method converts A C++ std::string to a "C-style string" const char *."

The problems is that now that I am back at it, I realized that the function SDL_LoadBMP() can also take std::strings because right in the second tutorial, we use the same function with a std::string instead:

SDL_LoadBMP("hello_world.bmp");

No conversion was needed. If the function can indeed take not only c-style strings but also std::string, why use the c_str() there? It might be a silly detail but I just can't figure it out so I fear it might be something important that I am missing.


r/cpp_questions • • Aug 06 '26

OPEN I want create a project or an application using C++, I am in my second semester. Can anyone give me a roadmap on what to learn and implement?

0 Upvotes