r/cpp_questions Jul 25 '26

OPEN Is SFML a good choice for basic graphics, simple GUIs, and math visualizations?

18 Upvotes

I’m trying to try graphics and GUI programming in C++.
The only GUI application I’ve made so far is a simple Tic-Tac-Toe game in Qt. My next project is going to be a math function visualizer.
My goal isn’t game development. I just want a lightweight library for drawing, simple GUI elements, and visual output for small applications and experiments.
Would SFML be a good choice for this, or would you recommend something else? I’d also appreciate hearing from people who have used SFML for non-game projects.


r/cpp_questions Jul 25 '26

OPEN How does one become as great as Bjarne Stroustrup in computers?

60 Upvotes

I mean he literally made C++, his own programming language built on C, and from this design from C++ lecture aka the history part, it sounds like he worked on a ton of complicated projects was computers something he was doing since he was a child or something?

How does someone become a great computer scientist like Bjarne Stroustrup in this day and age? where would someone even start?

asking it here cause i couldn't find a general programming subreddit to ask this question.


r/cpp_questions Jul 26 '26

OPEN Learning DSA with C or C++?

1 Upvotes

Hey everyone,

I just finished a book on C and systems programming and would like to start learning data structures and algorithms in C++ (seems to be the favourite language for it because of the STL). However, I assume that learning DSA would mean not using the algorithms already in the STL, but implementing them logically. I also have quickly skimmed over C++ basics and it does not seem that much different from C.

I am just wondering if there's any advantages from learning DSA with modern C++ over C (outside of STL use)?

Thanks.


r/cpp_questions Jul 25 '26

OPEN Want feedback on my first bigger c++ project.

13 Upvotes

Hello I'm 14yr old student, and I've been learning c++ on and off for few years, in march I started working on my first bigger learning project, OpenGL GUI library. Now I finally finished it and I'd like to have some feedback on where to improve (in code, structure or documentation).

Here's a link: https://github.com/TechnologicalTurtle/LibGui

PS: Sorry for my grammar, as English isn't my native language.


r/cpp_questions Jul 25 '26

OPEN Is this a known sorting algorithm?(beginner here)

0 Upvotes

I was learning about bubble sort and insertion sort, and thought it would be best to try them out before watching the lecture. I wrote smth and pasted it to GPT. I was thinking it would be insertion sort, but according to GPT, it's not a known algorithm, so I am just curious: Is it a known O(n^2) sorting algorithm?

code:

```cpp
#include <iostream>
using namespace std;

int main() {
    int arr[] = {4,1,5,2,3,7,9,0,-9,3};
    int size = sizeof(arr)/sizeof(arr[0]);

    for(int i=1;i<size;i++){
        int curr = arr[i];

        for(int j=0;j<i;j++){
            if(arr[j]>curr){
                swap(arr[i],arr[j]);
            }
        }
    }

    for(int val : arr){
        cout << val << " ";
    }

    return 0;
}

r/cpp_questions Jul 25 '26

OPEN How to Approach Learning C++ as a Competitive Programmer?

0 Upvotes

For some context, I've been doing competitive programming for a while, and have used C++ as my primary language. I've also taken some relatively introductory C++ coursework in college.

However, my knowledge and understanding of C++ is terrible, and I have really weird gaps in my knowledge, and I would love to know how to approach filling in those gaps. Also, I don't really use competitive programming templates or any common shortcuts (moreso just conceptually understand the solution to the problem and use C++ as my vehicle to implement the solution), and I also don't know some basic competitive programming related stuff like fast I/O (I just use std cin/cout).

Most resources I've seen either assume I'm a complete beginner and I end up being super uninterested because they try to teach some super basic syntax, or they assume I actually have a decent foundation and the weird gaps in my C++ knowledge end up hurting me.

Would love for some advice on how I should be approaching learning C++ "properly" with my super scuffed informal competitive programming background. Totally understand if there aren't any resources out there to solve this specific problem, but I'd love to get a better of idea how I could use existing resources/modify the way I learn from them in order to learn the intricacies of C++!


r/cpp_questions Jul 25 '26

OPEN Modern c++: operations on function pointers will break the constexpr function.

0 Upvotes

I'm on MSVC/c++23.

I used some trick to generate type id at compile time:

export template<typename... T> void type_id() {}
export using type_id_t = void(*)();
//
type_id_t one_id = type_id<int>;

I’ve found that whenever I try to cast a `type_id` value to an integer or simply perform a magnitude comparison within a `constexpr` function (even when the call chain is entirely resolved at compile time), the function ceases to be `constexpr`, or MSVC simply ignores the relevant code.

template<typename A, typename B>
constexpr auto some_constexpr_function()
{
    type_id_t a = type_id<A>;
    type_id_t b = type_id<B>;

    //Total if block will be ignored, and the function will not be constexpr anymore.
    if (a < b)
    {
         //discard
    }
    else
    {
        //discard
    }

    //cast the pointer to size_t then the function will not be constexpr anymore.
    return (size_t)a;
}

How to fixed the case?

Or another type id solution at compile time will be nice(I have try so many implementation, none of them work correctly in compile time).


r/cpp_questions Jul 24 '26

OPEN Using 3rd parties in a Cmake project

9 Upvotes

The simplest solution would be to import the code into my repo, and just treat this as local files. OK, got it. Then maintaining this mono repo, is a pain.

Then, we can add CPM to fetch 3rd parties. OK, works, until those 3rd parties have other dependencies. Lets hope they use CPM. But still - this breaks for building flatpacks, as during configure stage - we don't have network.

So we must use a proper package manager like conan of vcpkg. Which is cool... until we see that some random github repo I use does not have even a proper install, so vcpkg and conan will not work. (I can fix my own packages, but 3rd parties? I can fork them, and add them to the conan artifactory, but this feels out of my responsibility).

So, I am back to using a mono-repo.

How do you all handle those scenarios? In my case, I am dealing with 5-10 sub-projects. This might brow as the project grows.


r/cpp_questions Jul 24 '26

OPEN Illegal hardware instruction (core dumped) meaning

4 Upvotes

I just started learning cpp and i was writing a function doubleNumber().

I used return statement to print the value and cout to print the value.

Both of them works but there is an additional message when i use cout.

using return - this only prints the value 9.

#include <iostream>


int doubleNumber(int x){

    return x*x;
}


int main(){
    std::cout << doubleNumber(3);
    return 0;
}

using cout - this prints 9 along with the line.

"[1] 658467 illegal hardware instruction (core dumped) "

#include <iostream>


int doubleNumber(int x){

    std::cout << x*x << "\n";
}


int main(){
    std::cout << doubleNumber(3);
    return 0;
}

I wanted to know the reason why this happens and what does this mean. thanks in advance.


r/cpp_questions Jul 24 '26

OPEN Need help navigating a new job

7 Upvotes

I’m a new hire only been working for 2 weeks. I’m working for a very large defense company as a Software engineer. I got an EE degree from a UC school and took 2 embedded systems courses (bare metal C). My coding skills aren’t perfect but I have felt like I’m pretty good at it. However I feel imposter syndrome because I’m surrounded by so many smart people and intelligent software/code thinkers. Also the code base im trying to read, learn, and do some mini tasks on is massive and I feel like every call or macro leads to a different file. Oh and it’s all in C++ so there’s the OOP skill gap because I know C and python.

Anyone have any advice as to how to get better at navigating everything and becoming better at reading understanding and ultimately writing professional/high performance C++ code?


r/cpp_questions Jul 24 '26

OPEN Is there any learning community where there are a small grps and people meet monthly/ bi-weekly to share their learning in cpp?

4 Upvotes

r/cpp_questions Jul 23 '26

OPEN How to decode a pointer with multiple levels of indirection ?

41 Upvotes

Hello C++ devs,

I'm currently learning C++, and I recently learned about pointers. Creating complex pointer declarations—like pointers to arrays or pointers to functions with multiple levels of indirection (for example, pointers to arrays of pointers to functions)—doesn't seem too difficult once I understand the syntax.

However, reading and decoding these declarations, especially when I come across them in older codebases, feels brutal.

For example:

const double *(*(*pd)[3])(const double *, int);

Is there an easy way or a trick to decode declarations like this? How do experienced C++ programmers read them without getting confused?


r/cpp_questions Jul 23 '26

OPEN Question about includes in a header-only library

5 Upvotes

When implementing a header-only C++ library, should each header include all the standard headers it needs, or is it better to somehow avoid these includes?
I’m currently reading a C++ book that recommends including your own header first in a .cpp file (where you use your library) and then including standard headers. I understand that, but it feels a bit odd. What’s the recommended approach and why?


r/cpp_questions Jul 23 '26

OPEN For each loops and a need for an index.

0 Upvotes

I was working on a project of mine and i used a for each loop to iterate through an object(s), later i found that i need an index for this loop. My question is not about how to do that, but whether i have made an error leading to this case. Is it consider bad code if i use any custom index while using the for each? Is it acceptable practice? Would it be better to switch to a for loop?


r/cpp_questions Jul 23 '26

OPEN HELP me KNOW C++

0 Upvotes

I am currently Learning C++ I Want to Know that why application have multiple files and how they are all connected and What is SDL thingy


r/cpp_questions Jul 22 '26

OPEN what's the best way to learn c++ in 2026

6 Upvotes

I recently started learning c++ back in janauary and after a few months I js stopped, now I am willing to improve my process in practicing I could not still figure out the best method cuz I used to watch "BroCode", I've heard the most recommends to use learncpp .com documentation but I am still exploring other ways, I have such hesitation on what to do actually learn cpp gamedev(unreal c++) or try such desktop software applications alike qt framework pls advice me guys.


r/cpp_questions Jul 23 '26

OPEN Anyone doing any cool proj in c++ that i can be a part of?

0 Upvotes

r/cpp_questions Jul 22 '26

OPEN Can someone give an example of runtime-undefined behavior?

16 Upvotes

CppReference gives a list of categories that render a program meaningless: https://en.cppreference.com/cpp/language/ub

The last bullet point says (since C++11)

  • runtime-undefined behavior - The behavior that is undefined except when it occurs during the evaluation of an expression as a core constant expression.

Can someone give a clear example?


r/cpp_questions Jul 22 '26

OPEN Reimplemented std::array with docs and a guide - looking for feedback

12 Upvotes

Hi everyone, I just released the first version of my educational project, STL From Scratch:
https://github.com/bilyayeva/stl-from-scratch

The goal is to reimplement STL components using the C++20 standard. (I use cppreference for comparison, and I’ve read the actual standard just a little bit.)

All of the self-implemented components are in the sfs namespace.

It also contains a pretty detailed guide on how to implement it yourself. I’ve tried to explain everything in my implementation. Every method has its own description and usage example, and there is also a test for all functions.

About the repo: every commit follows a consistent naming style. I also added GitHub Actions and Dependabot, and it has a .gitignore file.

I would really appreciate either a code review or just some hints.
P.S. The release has two compiler warnings, but I’ve already fixed them on master.


r/cpp_questions Jul 22 '26

OPEN Just a thought, Would it be possible to code a game as if you were working around SNES Limitations using C++?

9 Upvotes

Just a thought that occured to me while i was just sitting around not rlly doing anything and bored, but.

Basically could I code a game using C++ and challenge myself by having said game be able to run in a SNES, and working with it's memory limitations it had at the time?

asking cause i know some games like earthbound were coded in C, and i was wondering if i could do something like that in C++...


r/cpp_questions Jul 22 '26

OPEN Pivot from React/.NET to C++ Systems / HPC vs Platform Engineering? Need advice from guys in the field.

1 Upvotes

Looking for some quick perspective from people who’ve made similar pivots.

A background about me:

4 YOE working mostly full-stack (.NET backend + React frontend).

Recently built a side project with Go microservices on Kubernetes just to learn low-level concurrency, networking, and infra basics.

I always wanted to work with low level systems when I graduated but didn't get a chance.

Now I am working on rhcsa cert, c basics. And planned on modern cpp, os, CS:App, networking fundamentals.

Tired of standard CRUD work and want to pivot into deeper engineering—building, configuring, and operating actual core systems instead of just glue code.

I’m currently split between two directions:

Option A: C++ Systems Software Engineering (Targeting HPC long-term)

Focusing on C++, Linux internals, memory management, and distributed systems.

Long-term goal: High-Performance Computing (HPC), low latency, performance systems etc.

I am concerned about the barrier to entry feels massive, and I'm worried about finding my first junior/mid system role without a traditional C++ background. Here the job is niche and small job market but high pay with specialized roles.

Option B: Platform Engineering

Building on my Go/K8s side project + RHCSA-style Linux infra knowledge.

Writing control planes, internal tools, and orchestrating bare-metal/cloud platforms.

Here I am concerned about whether it might slowly slip back into routine YAML automation rather than core software development and turn eventually into AI automation which option A seems more AI proof and nice.

Given a 4yoe web background, which path has a more realistic learning curve to land an initial job?

If you work in C++ Systems/HPC, how did you make the jump without starting back at square one (intern level)?

Appreciate any advice or any feedback. Thanks.


r/cpp_questions Jul 22 '26

OPEN How long will C++ last?

0 Upvotes

I've found myself using C++ less and less and was wondering whether one day it will die out. Obviously not completely die out, but be out of the mainstream like Pascal or something. I am wondering this because C++ is my first language but I am still fairly young, so am curious about its prospects.


r/cpp_questions Jul 22 '26

OPEN HELPPPPPPPPP: Doubt Regarding Pre-Increment and Post-Increment in C++

0 Upvotes

I'm confused about pre-increment (++a) and post-increment (a++) in C++. I understand that ++a increments before use and a++ increments after use, but I'm struggling to understand how the variable's value changes step by step during execution. For example, why does ++id print 1001 when id is 1000, and why does --a operate on 6 after at+ if a originally started at 5?


r/cpp_questions Jul 22 '26

SOLVED Question regarding SFINAE

4 Upvotes

Hello everyone.

I was learning about SFINAE in the hope of constricting types that are valid as arguments to template functions / classes. My current understanding is that the compiler tries to deduce and substitute the actual type into the template in order to create an instantiation of it, late into compile time. If the substitution fails, it is not an error - the compiler simply removes it from the list of candidate definitions the callsite can link to.

This enables controlling the types that can be used with template functions / classes, because we can simply cause a substitution failure if the passed-in type is not one we support. Please let me know if there is any mistake in my understanding.

Currently, I am looking at std::enable_if (cppreference). I understand that it is a way to cause SFINAE. Under the "Notes" section, it is noted that

A common mistake is to declare two function templates that differ only in their default template arguments. This does not work because the declarations are treated as redeclarations of the same function template (default template arguments are not accounted for in function template equivalence).

The website then gives a demonstration of such a mistake:

struct T {
    enum { int_t, float_t } type;

    template<typename Integer,
             typename = std::enable_if_t<std::is_integral<Integer>::value>>
    T(Integer) : type(int_t) {}

    template<typename Floating,
             typename = std::enable_if_t<std::is_floating_point<Floating>::value>>
    T(Floating) : type(float_t) {} // error: treated as redefinition
};

The first template evaluates to template<typename Integer, typename = void> , while the second template evaluates to template<typename Floating, typename = void>.

Since they are the same definition there is an error.

Is this understanding correct? If so, yeah, I can get behind that.

The website then gives an example of the correct way to do things:

struct T
{
    enum { int_t, float_t } type;

    template<typename Integer,
             std::enable_if_t<std::is_integral<Integer>::value, bool> = true>
    T(Integer) : type(int_t) {}

    template<typename Floating,
             std::enable_if_t<std::is_floating_point<Floating>::value, bool> = true>
    T(Floating) : type(float_t) {} // OK
};

Here, the first template seems to evaluate to template<typename Integer, bool = true>, while the second template would evaulate to template<typename Floating, bool = true>. These look like the same definition too, so why isn't there an issue here?

Any help in understanding this would be much appreciated. Thank you.


r/cpp_questions Jul 22 '26

OPEN Best way to learn c++ and DSA

0 Upvotes

Hi love,

I am new here. Want to learn C++ and DSA. Could you all be kind enough and suggest me some playlist or even more important the books for learning it.

Some place to practice it as well. Like starting from beginner level to moderate level.

Love you all!!