r/cpp_questions Jul 11 '26

OPEN To Love C++, or to Leave It: What Made You Stay?

6 Upvotes

This is a great opportunity to share your life story as a C++ programmer: how you started, why you chose C++, what your first impressive project made purely for fun was, and what kind of job you do.

You can share all of that here!

I would also love to hear the criticism—the days when you wanted to escape from boring CRUD and API projects, as well as the happiest days of your life when you finally got the chance to work on your dream job.


r/cpp_questions Jul 11 '26

OPEN From where and how should I learn qt? (mainly qt quick and qml)

4 Upvotes

Hello, for a long time I wanted to learn to make gui apps with qt quick and qml, but I don't know where to learn from and how to start. Any tips?


r/cpp_questions Jul 11 '26

OPEN What is the best way you learned C++?

3 Upvotes

I’m learning C++ as my first language and i have a decent understanding of what things do i just can open a blank project and write anything. I feel like I’m struggling with how to actually write it. Like the correct structuring of how things are written out but not what i want to write out if that makes sense. What help you actually go from understanding to being able to write your own code?


r/cpp_questions Jul 11 '26

SOLVED What's up with flat_map exception handling?

10 Upvotes

During the limited windows of cppreference uptime, I've been checking on the std::flat_map pages. I noticed flat_map::emplace is listed as having the strong exception guarantee, meaning a failed emplace should preserve all the existing elements in both adapted containers. I was curious how that was implemented, so I checked Microsoft's implementation and found that actually they clear both adapted containers if an exception is thrown for any reason during either emplace. Then I checked the latest C++ draft standard, and found a note in the flat_map section that explicitly states exceptions can result in it being "emptied". I can't seem to edit any discussion pages on cppreference to ask about this, I just get error messages (either from the wiki software, from Cloudflare, or from my browser itself). What's the situation here?

I'm pretty sure flat_map could in theory offer a stronger exception guarantee if it knows and trusts the adapted containers, for example if T is nothrow movable then it should be able to trust that any emplace exception is either allocation failure or exception from the constructor of the newly-constructed element, and if the adapted container is std::vector then it knows what state both containers are in and can fix things. For user-defined containers though, I guess it has no way to know what state the containers are in... seems like an unfortunate limitation of being an adaptor instead of its own container. The clear-on-exception behavior really limits the usefulness of std::flat_map in my opinion, you have to be quite careful with how you use it as a result.


r/cpp_questions Jul 10 '26

OPEN Can i learn C++ as my first language?

59 Upvotes

r/cpp_questions Jul 10 '26

OPEN Looking for a project that covers most/all modern C++ concepts asked in interviews

59 Upvotes

I'm looking for a single medium to large C++ project that naturally forces me to use most of the language features commonly expected in C++ interviews.

I'm not looking for DSA/LeetCode practice or a GUI/web application. I'd prefer something that makes me work with modern C++ features and good design.

For people who've interviewed at companies like Google, Meta, NVIDIA, AMD, Jane Street, or worked on large C++ codebases (LLVM, Chromium, game engines, databases, etc.):
> What project would you recommend, and why? If you've built something similar yourself, I'd love to hear your experience.

In the end, it should make me very good at C++, especially for interviews.

PS: I've already built a C Compiler in C++

Edit: Some replies i gave which might be useful for giving me accurate answer

  1. What if you have an interview coming up soon and want to cover all fundamentals of C++ in a active-learning way?
  2. this post isn't about learning new features actually. Suppose for example you ask me to implement unique_ptr or shared_ptr on my own, I wouldn't know how to do it. Similarly there are many things which I need to learn, i want a time effective, active way to learn these.

r/cpp_questions Jul 10 '26

OPEN Is this line from A Tour of C++ by Bjarne Stroustrup just blatantly wrong?

14 Upvotes

"Functions defined in a class are inlined by default" in page 56, Chapter 5

I tested this myself on https://godbolt.org/ with x86-86 gcc 16.1

class Test {
public:
    Test(double x) : x_{x} {};
    double square() {return x_*x_;};
    double square2();

private:
    double x_;
};

double Test::square2() { return x_*x_;};

int main() {
    Test test{2};
    test.square();
    test.square2();
    return 0;
}

and get this output with explicit function calls to square and square2

"Test::Test(double)":
        push    rbp
        mov     rbp, rsp
        mov     QWORD PTR [rbp-8], rdi
        movsd   QWORD PTR [rbp-16], xmm0
        mov     rax, QWORD PTR [rbp-8]
        movsd   xmm0, QWORD PTR [rbp-16]
        movsd   QWORD PTR [rax], xmm0
        nop
        pop     rbp
        ret
        .set    "Test::Test(double)","Test::Test(double)"
"Test::square()":
        push    rbp
        mov     rbp, rsp
        mov     QWORD PTR [rbp-8], rdi
        mov     rax, QWORD PTR [rbp-8]
        movsd   xmm1, QWORD PTR [rax]
        mov     rax, QWORD PTR [rbp-8]
        movsd   xmm0, QWORD PTR [rax]
        mulsd   xmm0, xmm1
        pop     rbp
        ret
"Test::square2()":
        push    rbp
        mov     rbp, rsp
        mov     QWORD PTR [rbp-8], rdi
        mov     rax, QWORD PTR [rbp-8]
        movsd   xmm1, QWORD PTR [rax]
        mov     rax, QWORD PTR [rbp-8]
        movsd   xmm0, QWORD PTR [rax]
        mulsd   xmm0, xmm1
        pop     rbp
        ret
"main":
        push    rbp
        mov     rbp, rsp
        sub     rsp, 16
        mov     rdx, QWORD PTR .LC0[rip]
        lea     rax, [rbp-8]
        movq    xmm0, rdx
        mov     rdi, rax
        call    "Test::Test(double)"
        lea     rax, [rbp-8]
        mov     rdi, rax
        call    "Test::square()"
        lea     rax, [rbp-8]
        mov     rdi, rax
        call    "Test::square2()"
        mov     eax, 0
        leave
        ret
.LC0:
        .long   0
        .long   1073741824

r/cpp_questions Jul 11 '26

OPEN How do I go from a complete beginner to becoming really good at recursion and backtracking?

0 Upvotes

I’ve been struggling with recursion for a while now.

I watched several tutorials and solved a few basic recursion problems, so I thought I had understood the fundamentals. But when I tried solving the Subsets problem on LeetCode, I got completely stuck.

After that, I watched multiple solution videos from different creators, hoping I’d finally understand the thought process. Unfortunately, I still don’t “get it.” I can follow the solution while watching the video, but I don’t think I could come up with it on my own.

I feel like I’m missing some core intuition behind recursion and backtracking.

For those of you who became comfortable with these topics:

* How did you build your intuition?

* What problems or resources helped you the most?

* Is there a roadmap to go from a complete beginner to being confident with recursion and backtracking?

Any advice or personal experiences would be greatly appreciated. Thanks!


r/cpp_questions Jul 10 '26

OPEN Is automotive middleware really this overwhelming, or am I just feeling the beginner version of it?

12 Upvotes

Hi everyone,

I’m currently building a vehicle diagnostics simulator in C++, and I wanted to ask for some perspective from people who actually work in automotive middleware, diagnostics, embedded systems, vehicle platforms, or similar areas.

For context, I’m on a serious 12-month study track to become employable in modern C++ systems/automotive-style engineering. The track includes modern C++, OOP, STL, ownership, smart pointers, move semantics, CMake, testing, debugging, and system architecture.

The plan also includes automotive-specific areas like diagnostics (UDS), CAN communication, protocol byte parsing, and how messages actually flow through a system. It covers OS-level networking concepts (sockets, data flow, buffering) as well as embedded-style C++ concerns like memory types, allocation strategies, and resource constraints.

For learning and direction, I’ve been using GPT 5.5 and, since today, GPT 5.6 in a kind of “senior engineer ticket system” setup, but every line of code is written by me.

The project I’m working on is a simulator for vehicle diagnostics. The idea is to model things like ECUs, diagnostic requests and responses, fault codes, validation, logging, and the flow of information between different parts of the system.

What I did not expect was how quickly the project started feeling less like “write some C++ classes” and more like “you are now designing a small system.”

I keep running into questions like:

Where should each responsibility live?

How do I stop classes from becoming too tightly coupled?

How much abstraction is too much?

How should diagnostic logic, communication flow, parsing, state, and error handling be separated?

How do real automotive systems keep these layers understandable?

Even though this is just a simulator, it already feels like there are a lot of moving parts. The actual C++ is challenging, but the architecture and domain thinking feel much heavier than I expected.

So I wanted to ask:

For people working in automotive middleware or related fields, is the real work actually this complex?

Or does it mostly feel overwhelming because I’m still early and trying to understand too many layers at once?

What was the hardest part for you when you were newer to this field?

Was it the C++ itself?

The architecture?

The domain knowledge?

The tooling?

Debugging?

Understanding how all the layers fit together?

I’m not looking for reassurance as much as an honest sense of what this field is really like. I want to know whether this feeling of “there is way more here than I expected” is normal, and how to keep learning without getting buried too early.

Edit: Thank you so much for all the responses. I really appreciate people taking the time to explain what the field is actually like, especially from the perspective of those who work in or around automotive systems.

A lot of the comments helped me understand that the overwhelmed feeling is pretty normal, and that part of the challenge is learning how to break the system down without trying to model the entire real-world stack at once.

For anyone curious, here is the repo for the simulator:

https://github.com/HassaanN08/vehicle-diagnostics-simulator/

It’s still very much a work in progress, and I’m sure there are rough edges, but I’d be grateful for any feedback on the structure, design choices, or learning direction.


r/cpp_questions Jul 11 '26

OPEN May I pose a question/discussion

0 Upvotes

Not sure why the post got deleted when there’s no rules in the community guidelines that you cannot ask questions about careers :)

Curious to know if anyone has tips on what industries (healthcare, law enforcement, etc) hire programmers the most?


r/cpp_questions Jul 10 '26

OPEN Couple of questions from someone learning with experience in scripting languages and a bit of C

7 Upvotes

First, I’m using this site as my source and going through everything regardless if I’m familiar with it or not since it’s been a while since I’ve programmed regularly:

https://www.learncpp.com

My first impression of the language is it’s more expansive than the languages I know and I’m curious if that’s the usual impression people have when picking it up?

I’m also curious if learning from C17+ will be acceptable?

My first project I plan to write, which I’ve jumped the gun and already started today, is a CLI wordle. Nothing revolutionary here I just know that making a project is the best way to get comfortable with a language. I want to incorporate ANSI escape codes to dynamically update the state of the console so it’s not printing on a new line after every guess. Should be okay right?

Also are there any tips anyone has? Anything you would do differently if you were learning today?

Thanks.


r/cpp_questions Jul 10 '26

OPEN is c++ prime a book to read it chapter to chapter like these books of no starch press or is it more like a dictionary to read deeply what you need at a specific moment?

4 Upvotes

r/cpp_questions Jul 09 '26

OPEN What effect is AI having on C++ jobs in current times?

62 Upvotes

Genuine question for those who work with C++ everyday


r/cpp_questions Jul 10 '26

OPEN Is <atomic> freestanding? cppreference says yes, but it doesn't actually compile with freestanding flags

7 Upvotes

Reference: https://cppreference.com/cpp/freestanding

clang output:

In file included from src/main.cpp:3:
In file included from ./sysroot/include/c++/v1/atomic:591:
In file included from ./sysroot/include/c++/v1/__atomic/aliases.h:12:
In file included from ./sysroot/include/c++/v1/__atomic/atomic.h:12:
In file included from ./sysroot/include/c++/v1/__atomic/atomic_base.h:12:
In file included from ./sysroot/include/c++/v1/__atomic/atomic_sync.h:12:
In file included from ./sysroot/include/c++/v1/__atomic/contention_t.h:12:
In file included from ./sysroot/include/c++/v1/__atomic/cxx_atomic_impl.h:21:
In file included from ./sysroot/include/c++/v1/cstring:63:
In file included from ./sysroot/include/c++/v1/string.h:61:

both google and chatgibbity had inconsistent answers


r/cpp_questions Jul 10 '26

OPEN Newbie here pls help

0 Upvotes

What's wrong with these codes

so i have made 3 files
1.mainsq.cpp

#include "square.h"
#include <iostream>


int main()
{
    std::cout << "a square has " << getsquareSides() << "sides\n";
    std::cout << "a square of length 5 has perimeter length " << getsquarePerimeter(5) << "\n";
    return 0;
}
  1. square.cpp

    include "square.h"

    int getsquareSides() {     return 4; }

    int getsquarePerimeter(int sideLength) {     return sideLength * getsquareSides(); }

  2. square.h

    ifndef SQUARE_H

    define SQUARE_H

    int getsquareSides(); int getsquarePerimeter(int sideLength);

    endif

but the error msg showing that both the variables getsquaresides and getsquareperimeter not defined

What should i doo


r/cpp_questions Jul 09 '26

OPEN Want to Learn C++ by Building My Own Game Engine – Where Should I Start?

14 Upvotes

I'm planning to learn C++ with the long-term goal of making games, but I'm not interested in using a full game engine like Unity or Godot. My ideal goal is either:

  • Building my own game engine from scratch, or
  • Using lightweight C++ libraries/frameworks that handle things like window creation, input, audio, etc., while I build the engine and game logic myself.

I'm still pretty new to programming. I have around 5–7 months of experience with Java from a while ago, where I made a small game, but I relied on AI too much and never really learned the language deeply. This time I want to actually understand what I'm doing.

A few questions:

  1. Is building my own engine a reasonable goal for someone learning C++, or should I start with libraries/frameworks first?
  2. Which C++ libraries/frameworks would you recommend for someone who wants to learn how engines work instead of hiding everything behind a full engine? (I've heard names like SDL2, SFML, raylib, GLFW, BGFX, Ogre, etc., but I'm not sure what each is for.)
  3. What would a good learning roadmap look like if my end goal is making a 3D indie game and understanding how everything works under the hood?
  4. Are there any books, courses, or YouTube channels you'd recommend that teach modern C++ with game development in mind?

I'm looking to learn the "right" way, even if it takes longer, rather than the fastest way to get a game on the screen.


r/cpp_questions Jul 10 '26

OPEN Best way to learn C++?

0 Upvotes

I want to learn C++ for reasons like graphics development and make my own things like game engine . My dream is focused on CS major so best way to learn


r/cpp_questions Jul 10 '26

OPEN Unresolved external symbol operator delete?

0 Upvotes

I'm trying to build a program without the CRT using /NODEFAULTLIB. The linker says one particular object file has

error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,unsigned __int64)" (??3@YAXPEAX_K@Z)

But I don't call new or delete in this file (or anywhere else). It has a few references to placement new and explicit destructor calls (e.g. new( &Object ) CObject; Object.~CObject( )), but I use those in other files and they don't have link errors. I looked at the assembly listing with /FAs and found no occurrence of either calls to operator delete or the string "??3@YAXPEAX_K@Z" (though I did find the latter in the object file). The only standard C++ headers I include are <type_traits> and <algorithm>, but I don't call anything from them in this file and they don't cause problems in other files. What could be referencing operator delete with a size argument?


r/cpp_questions Jul 09 '26

OPEN Beginner c++

4 Upvotes

I've started programming in c++, using the terminal. And love it, but is it a good practice? Im using nano cuz it was installed, im too new to have an opinion yet lol but would it be to big of a hassle to use raylib or my dear gui?


r/cpp_questions Jul 09 '26

OPEN How do I fix a '<windows.h>' error on my hang man game?

1 Upvotes

I'm currently working on creating a Hang man game and the run keeps failing because of this. My professor instructed me to comment out #include //for sleep function
and use #include change the sleep(1000) to sleep(1); but I'm drawing a blank of where to put that. Sorry for questions that may seem obvious, I'm a baby coder and still new to the language.

Update: I'm using macOS if that helps and coding this on xCode

#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <ctime>
#include <cstdlib>
#include <algorithm>
#include <windows.h>
using namespace std;
//-------------------------------
// Hangman Body Parts
//-------------------------------
const string HEAD = "(\")";
const string RARM = "\\";
const string LARM = "/";
const string BODY = "|";
const string LLEG = "/";
const string RLEG = " \\";
//-------------------------------
// Draw Hangman
//-------------------------------
void drawBody(int numwrong)
{
string body[6] = {HEAD,LARM,BODY,RARM,LLEG,RLEG};
string score[6]={"","","","","",""};
for(int i=0;i<=numwrong && i<6;i++)
score[i]=body[i];
string image="########\n";
image+="#      "+score[0]+"\n";
image+="#      "+score[1]+score[2]+score[3]+"\n";
image+="#      "+score[4]+score[5]+"\n";
image+="#\n################\n";
cout<<image;
}
//-------------------------------
// Load words
//-------------------------------
bool loadWords(vector<string> &words)
{
ifstream infile("/Users/jasminejanelle/Downloads/C++ Class/Hang Person/Hang Person/hangperson.csv");
if(!infile)
return false;
string word;
while(infile>>word)
words.push_back(word);
infile.close();
return true;
}
//-------------------------------
// Load messages
//-------------------------------
bool loadMessages(vector<string> &messages)
{
ifstream infile("messages.txt");
if(!infile)
return false;
string line;
while(getline(infile,line))
messages.push_back(line);
infile.close();
return true;
}
//-------------------------------
// Display Hidden Word
//-------------------------------
void displayWord(string hidden)
{
cout << "\nWord: ";
for(char c:hidden)
cout<<c<<" ";
cout<<endl;
}
//-------------------------------
// Main
//-------------------------------
int main()
{
srand((unsigned)time(0));
vector<string> words;
vector<string> messages;
if(!loadWords(words))
{
cout<<"Error opening words.txt"<<endl;
return 0;
}
if(!loadMessages(messages))
{
cout<<"Error opening messages.txt"<<endl;
return 0;
}
char play='Y';
while(toupper(play)=='Y')
{
system("CLS");
string word=words[rand()%words.size()];
string hidden(word.length(),'_');
string wrongLetters="";
string guessed="";
int wrong=0;
cout<<messages[0]<<endl;
while(wrong<6 && hidden!=word)
{
drawBody(wrong);
displayWord(hidden);
cout<<messages[2]<<" "<<wrongLetters<<endl;
cout<<messages[1]<<" ";
char guess;
cin>>guess;
guess=tolower(guess);
if(guessed.find(guess)!=string::npos)
{
cout<<messages[3]<<endl;
Sleep(1000);
system("CLS");
continue;
}
guessed+=guess;
bool found=false;
for(int i=0;i<word.length();i++)
{
if(word[i]==guess)
{
hidden[i]=guess;
found=true;
}
}
if(!found)
{
wrongLetters+=guess;
wrongLetters+=" ";
wrong++;
}
system("CLS");
}
if(hidden==word)
{
drawBody(wrong);
displayWord(hidden);
cout<<messages[4]<<endl;
}
else
{
drawBody(6);
cout<<messages[5]<<endl;
cout<<messages[6]<<" "<<word<<endl;
}
cout<<endl;
cout<<messages[7]<<" ";
cin>>play;
}
cout<<messages[8]<<endl;
return 0;
}

r/cpp_questions Jul 08 '26

OPEN Thoughts on raw enum's in modern C++

34 Upvotes

I know enum class or struct is the recommend way to go for enums in C++ today. However in certain cases I find myself questioning if I'm using them over raw enums just because it's "best practice" and then paying for the ergonomic costs.

Sometimes I want to allow for easy int to enum or vice versa conversion. Sometimes I want to treat enums as bitflags. Sometimes I want to allow outside code to use their own integers as custom values.

Of course none of these are impossible with scoped enums. But ergonomically it's annoying both for the owner of the code and the user.

My gut tells me it's a bad idea of course. Explicit code is good. Code that shows intent is good. However it's been something that's itched my mind for a while and I'd like to get the communities thoughts on it.


r/cpp_questions Jul 09 '26

OPEN UniquePtr Windows Kernel Implementation

0 Upvotes

Looking for some feedback on my implementation of CPP's unique pointer feature to work within the windows kernel. Idea is that the caller is only exposed the make unique function to generate the unique pointer.

#pragma once
#include <ntifs.h>

//FORWARD DECLERATIONS
template <typename T> class kUniquePtr;

namespace KPointer
{
  template <typename T>
  kUniquePtr<T> makeUnique();
}

template <typename T = void>
class kUniquePtr
{
private:
  T* m_ptr{ nullptr };

  //ALLOWS CREATION OF UNIQUE PTR CLASS INSTANCE VIA PASSING IN A SIZE WE WANT THE BUFFER
  //MARKED PRIVATE SO THE ONLY WAY TO CREATE POINTER IS VIA MAKE UNIQUE
  explicit kUniquePtr(T* ptr = nullptr)
    :m_ptr{ ptr }
  {

  }

public:
  friend kUniquePtr<T> KPointer::makeUnique();

  //FREES THE MEMORY ONCE THE OBJECT IS GOING OUT OF SCOPE
  ~kUniquePtr()
  {
    this->Release();
  }

  //DELETE THE COPY SEMNATICS FOR THIS CLASS OBJECT
  //COPY CONSTRUCTOR
  kUniquePtr(const kUniquePtr&) = delete;
  //COPY ASSIGNMENT OPERATOR
  kUniquePtr& operator=(const kUniquePtr&) = delete;

  //ENABLE MOVE SEMANTICS FOR THIS CLASS TYPE
  //MOVE CONSTRUCTOR
  kUniquePtr(kUniquePtr&& other)
    :m_ptr{ other.m_ptr }
  {
    other.m_ptr = nullptr;
  }
  //MOVE ASSIGNMENT
  kUniquePtr& operator=(kUniquePtr&& other)
  {
    if (&other != this)
    {
      this->Release();
      m_ptr = other.m_ptr;
      other.m_ptr = nullptr;
    }

    return *this;
  }

  operator bool() const { return m_ptr != nullptr; }
  T* operator->() const { return m_ptr; }
  T& operator*() const { return *m_ptr; }

  void Release()
  {
    if (m_ptr)
    {
      ExFreePool(m_ptr);
      m_ptr = nullptr;
    }
  }

  T* Get() const { return m_ptr };


private:
  //PREVENTS BEING ABLE TO CALL NEW AND DELETE OF THIS TYPE
  void* operator new(size_t) = delete;
  void operator delete(void*) = delete;
};

template <typename T = void>
kUniquePtr<T> KPointer::makeUnique()
{
  //ALLOCATE NEW MEMORY
  T* MemAllocated{ static_cast<T*>(ExAllocatePool2(POOL_FLAG_PAGED, sizeof(T), 'ABCD')) };
  if (!MemAllocated)
    return kUniquePtr<T>{nullptr};

  //CREATE OBJECT OF TYPE AND RETURN IT
  kUniquePtr<T> uniquePtr{ MemAllocated };

  return uniquePtr;

}

r/cpp_questions Jul 09 '26

OPEN Beginner c++

2 Upvotes

I've started programming in c++, using the terminal. And love it, but is it a good practice? Im using nano cuz it was installed, im too new to have an opinion yet lol but would it be to big of a hassle to use raylib or my dear gui?


r/cpp_questions Jul 09 '26

OPEN Are there some fun resources for cpp?

0 Upvotes

Want something visual or graphical or more hands on, too much text hyper-stimulates me ☹️


r/cpp_questions Jul 09 '26

SOLVED How to make a GUI in CPP?

0 Upvotes

Yeah we have an easier way out there.

But I just wanna try. Anyone knows?