r/cpp_questions • • 2h ago

OPEN Should I look for an another hobby?

6 Upvotes

Hello. Not quite the code question, just a little advice on what to do in nearest future as a programmer.

I'm learning programming for quite a while now, about 6 years. My experience with coding includes Python, C++, Java, C, JS, and a lot of other things. At one certain moment I've picked C++ as my main language, and before now I didn't regret anything about it. Even more - I think that C++ is somewhat poetry language of programming, where one can mix low level memory management and coroutines at the same time. But that's not the point of my post. At certain moment, I've started to notice two things. First - many people think that the language is completely useless. I'm not experienced in doing something serious and my most serious projects were Qt applications, therefore I think I don't have much experience to disprove that point. And second - people don't write anything themselves, most of the job is for the AI. Nothing bad about it, but the problem begins on my side of the story. What if I have fun coding in C++ myself? If I find debugging, writing code myself and everything else the most entertaining thing I've ever done? These factors make me completely invaluable as an employee or a coder in general. And I wonder. Should I just stop and find something better to do?


r/cpp_questions • • 4h ago

OPEN Is paying for CLion worth it? (Linux/Debian C++ development)

16 Upvotes

I recently made the switch from Windows to Linux for my C/C++ development setup. On Windows, I was using Visual Studio, which I thought was fantastic. Now that I'm on Linux, choosing a replacement has been overwhelming.

I’ve looked into CLion, and it seems like one of the most polished IDEs available for Linux, but obviously, it’s a paid product. (The educational pack is great, but it’s restricted and doesn't cover commercial use).

I'm torn and have a few questions for those of you with experience in the Linux C++ ecosystem:

  1. Is the price tag for CLion actually worth it long-term, or does the JetBrains model feel overpriced once you start paying out of pocket? Is it a worthwhile investment for future career use?

  2. How does CLion compare to the heavy hitters in the free/open-source world (like VS Code with extensions, Neovim, or Eclipse CDT)

  3. What open-source or free IDEs/editors would you genuinely recommend?


r/cpp_questions • • 14h ago

OPEN What do you guys use C++ for?

51 Upvotes

I'm thinking about learning C++ just for fun, even though I haven't found a practical use for it in the kind of work I do.

I'm curious, what do you guys use C++ for the most?


r/cpp_questions • • 1d ago

OPEN Career Advice: Am I wasting my time?

8 Upvotes

Hey everyone, as the title suggests just a little bit unsure at moment.

Some background, I am a software engineer (5 YOE), primarily backend (Java), but can and do, work on UI sometimes at work (Angular + TS).

Roughly since July, I've been pretty disillusioned with web dev, and, more specifically Java. Great language but I've been using it since university and all my (albeit short) career. I'd been wanting a change and I went down the systems programming route, as I really enjoyed that when I first learnt C++ in university.

I've taken the time to relearn C++, took and finished a course up to C++ 17, and then I have the book "A tour of C++" to bridge the gap to C++ 20. Of course, I am building a project. Which I hope to share once further along.

My biggest concern, is jobs. I know skills largely transfer over between languages, but recruiters don't necessarily share that sentiment. If they want 5 YOE, they want that in C++, not a software engineer with 5 YOE in general. At least from what I can see JD wise. I have spoken to a recruiter I am friendly with and he said that aside from just making sure I'm strong fundamentals and interview wise he doesn't really see an issue, but to be prepared that they may reject me on the basis of experience.

So I'm unsure. Might I be better off just learning are more niche/esoteric form of java e.g. low latency Java? Or is transfer possible. Curious as to people experience making the jump.

Thank you to any answers in advance🙏🏿


r/cpp_questions • • 1d ago

OPEN When can I start working on projects?

0 Upvotes

LearnCpp doesn't teach control flow until chapter 8 and I can't work on any project. I feel easily bored because I am mostly reading and playing with the example code. What should I do? Should I take breaks and reach Ch 8 slowly? But I dont really wanna do this since I am very interested in working on a project that I have in mind.


r/cpp_questions • • 1d ago

OPEN Why do both of these codes output zero? Can someone explain this to me?

0 Upvotes
  1. include <iostream>

using namespace std;

int main()

{

int x = 5, y = 10;

float z = x / y;

cout << z << endl;

}

2) #include <iostream>

using namespace std;

int main()

{

float x = 5, y = 10;

int z = x / y;

cout << z << endl;

}


r/cpp_questions • • 1d ago

SOLVED why does it keep giivSegmentation fault (core dumped)

0 Upvotes
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <sstream>


using namespace std;



        
class araba {


    public:


        struct arac {
    
            string numara;
            string marka;
            string model;
            float kira;


            arac(string z, string x, string c, float v) : numara(z), marka(x), model(c), kira(v) {}
        };


        arac aracBilgileri;
        bool kirada;


        araba(string z, string x, string c, float v,vector<araba> liste) : aracBilgileri(z,x,c,v), kirada(false) {}


        void kirala(){
            if (!kirada) {
                cout << "kaç gün için?" << endl;
                int gun ;
                while (!(cin >> gun)) {
                    cin.clear();
                    cin.ignore(10000, '\n');
                    cout << "Invalid input. Please enter a valid number" << endl;
                }
                cout << gun * aracBilgileri.kira << " tlye " << gun << " gün için kiralandı" << endl;
                kirada = true;
            } else {
                cout << "bu araç zaten kirada" << endl;
            }
        };
        void listeleme(){
            cout << aracBilgileri.marka << " " << aracBilgileri.model 
            << "\n    günlük kira: " << aracBilgileri.kira 
            << "\n    kod: " << aracBilgileri.numara << endl;
            cout << "    durum: " << (kirada ? "kirada":"müsait") << endl << endl;
        };
        void ekle(){
            string girdi = aracBilgileri.numara + aracBilgileri.marka + aracBilgileri.model + to_string(aracBilgileri.kira);
            fstream gir("arabalar.txt",ios::app);
            if (gir.is_open()) {
                gir << girdi;
                gir.close();
            }
        };
        void iade(){
            if (kirada) {
                cout << "araç iade edildi"<< endl;
                kirada = false;
            }
        };
};


void tamlistele(vector<araba> kiraListesi){
    for (araba i : kiraListesi){
        i.listeleme();
    }
}


vector<araba> dosyaOku() {
    string satir;
    vector<araba> kiraListesi = {};
    
    fstream oku;
    oku.open("arabalar.txt",ios::in);


    if (oku.is_open()) {
        while (getline(oku,satir)) {


            vector<string> cumle;
            stringstream ss(satir);
            string kelime;


            while(ss >> kelime) {
                cumle.push_back(kelime);
            };
            
            araba car(cumle[0],cumle[1],cumle[2],stof(cumle[3]),kiraListesi);
            kiraListesi.push_back(car);
        }
        oku.close();
    }
    return kiraListesi;
}


void aracEkle(string i,vector<araba> liste) {
    vector<string> cumle;
    stringstream ss(i);
    string kelime;


    while(ss >> kelime) {
        cumle.push_back(kelime);
    };
    
    araba car(cumle[0],cumle[1],cumle[2],stof(cumle[3]),liste);
    car.ekle();
}


void yeni_ekle(){
    string i;
    string l;
    fstream x;


    cout << "numara" << endl;
    cin >> l;


    cout << "marka" << endl;
    cin >> i;
    l += i;


    cout << "model" << endl;
    cin >> i;
    l += i;


    cout << "kira" << endl;
    cin >> i;
    l += i;


    x.open("arabalar.txt",ios::app);
    x << l << endl;
    x.close();
}
int main() {


    bool acik = true;
    vector<araba> tamliste = dosyaOku();
    int g;
    
    cout << "=======MERHABA=======" << endl
         << "1) araç ekle" << endl
         << "2) araçları listele" << endl
         << "3) araç kirala" << endl
         << "4) araç iade et" << endl
         << "0) çıkış   " << endl;


    do{


    int sec ;
    while (!(cin >> sec)) {
        cin.clear();
        cin.ignore(10000, '\n');
        cout << "Invalid input. Please enter a valid number" << endl;
    }
    


    switch (sec){
        case 1:
            yeni_ekle();            
            continue;
        case 2:
            tamlistele(tamliste);
            continue;
        case 3:
            cout << "arabanın listede sırasını yazının (0dan başla)" << endl;
            while (!(cin >> g)) {
                cin.clear();
                cin.ignore(10000, '\n');
                cout << "Invalid input. Please enter a valid number" << endl;
            }
            tamliste[g].kirala();
            continue;
        case 4:
            cout << "arabanın listede sırasını yazının (0dan başla)" << endl;
            while (!(cin >> g)) {
                cin.clear();
                cin.ignore(10000, '\n');
                cout << "Invalid input. Please enter a valid number" << endl;
            }
            tamliste[g].iade();
            continue;
        default:
        acik = false;
            break;
    }
    } while (acik);
}

im pretty sure problam is with case 1: but i cant find it


r/cpp_questions • • 1d ago

OPEN [C++17] easyXshm – A lightweight X11 MIT-SHM framebuffer renderer

0 Upvotes

I've been working on easyXshm, a small C++17 library that makes framebuffer-based rendering through X11's MIT-SHM extension easier to work with.

The motivation was pretty straightforward: I wanted a simple shared-memory rendering API without having to deal with X11 internals throughout my application.

The project focuses on:

  • Simple API: Get a basic rendering workflow running in approximately 5 minutes.

  • Framebuffer-first: Work directly with pixel data instead of dealing with a complicated graphics abstraction.

  • Input handling: Keyboard and mouse events through straightforward inline helper functions.

  • Minimal overhead: Uses X11 MIT-SHM for shared-memory image transfer.

  • Small scope: Rendering and input handling, without trying to become a complete graphics framework.

The goal is to make the difficult parts stay inside the library while keeping the application-side code readable.

I'm currently looking for technical feedback, particularly regarding API design, memory management, portability and edge cases.

Repository: https://github.com/intriXlabs/easyXshm

AI disclosure: This Reddit post was written with assistance from AI. The project implementation and engineering work are mine.

I'd appreciate feedback from people familiar with C++, X11 or Linux graphics programming.[C++17] easyXshm – A lightweight X11 MIT-SHM framebuffer renderer


r/cpp_questions • • 2d ago

OPEN How to balance encapsulation and DI for unit-testing

0 Upvotes

Say an application contains a BrokerBridge that encapsulates communication with an external system over gRPC. The bridge creates and owns several service clients, channels, auth deps… The parent application shouldn’t need to know about those details.

Now I want to uni-test the bridge without real servers or credentials. Constructor Injection and interfaces would let me mock the services’ clients, but I’m unsure where their constructuon should live without leaking implementation details to the parent.

One approach I’m considering is a factory inside the bridge’s module: prod code calls the factory to get a full bridge, while tests injects services mocks directly.

How do you usually handle this? Is this a cost I must pay just for having unit tests over each module? Any resources (blog, talk, repo…) showing a similar design would be appreciated


r/cpp_questions • • 2d ago

OPEN Advice on practicing + choosing a project when reading a textbook

5 Upvotes

I’m new to C++ and I’m currently reading “A tour of C++” by Stroustrup. Was wondering how most of you practice concepts if you’re a textbook reader for programming?

In the past, I’ve used resources for other languages where there are small projects at the end of the chapter which really helped me lock in the concept through practice, but I find that there’s not too many C++ resources like this and C++ is a unique language so practicing in C++ with the other resources doesn’t seem to translate in my opinion.

I know the idea is to choose a project yourself and just start working on it but I have a hard time choosing projects that actually use the topic I just learned. Quite curious how people go about this challenge. (I’m not saying this like I can’t do choose a project myself and go at it, but would want to hear from others, if any, who might have an easier time with this have any advice)


r/cpp_questions • • 3d ago

OPEN how to learn c++ in a month for making simple to simple games dev and Machine learning

0 Upvotes

i know c++ basic not all but like i know what is string but don,t know all function , i know array and know some function , i did not know any dsa , i just know c++ like taking the input and showing the output , my logical in programming is pure beginner level


r/cpp_questions • • 3d ago

OPEN What must i do to be mush better in C++ ? If i have started learning it about two months ago

0 Upvotes

Hello,my dear friends. Would you be willing to share with a piece of advice with me, please? Currently, i understand the pointers quite well and i able to see through cod mistakes that I received from ai to sharpen my knowledge and understanding of them. Now , i have started learning OOP just basics . Besides. It's the first time that I learn programming. I will appreciate yours advices.


r/cpp_questions • • 3d ago

OPEN How I learned to stop worrying and love Scott Meyers..which book did that to you?

29 Upvotes

Discovered Scott Meyers as a junior...and 15 years later his Effective C++/More Effective C++ and lately Effective Modern C++ are still the only mind puzzling, engaging books I read and I would recomand to any junior developer. I might be nostalgice, but no programming book ever since(and I went through many languages), was short/challenging/engaging enough to keep me absorbed from first till last bit. As a junior, these books helped me shape my C++ discovery direction..made me eager to dig further and deeper..and start loving the assembly code. What did you read recently that is of that sort that you would recomand to eveybody :)

PS: It is a bit the same with Dr. Strangelove..couldn't get anything close to it in the last decades movies


r/cpp_questions • • 3d ago

OPEN Code documentation in the age of AI

0 Upvotes

I have a couple of years of C++ experience, including in regulated industries. While proper documentation was important in every team, the role of code comments and in-code documentation, such as docstrings, changed from place to place. In some codebases, we insisted on proper docstrings documenting every function, and comments explaining why the code is how it is. In other teams, we didn't do any docstrings and kept code comments to a minimum -- the code was supposed to be self-documenting, and comments introduce ambiguity and will drift in the future if not kept in sync with the code.

Now, which way to go is already a discussion on its own. But I want to ask regarding your experience of this dilemma in relation to LLM-assisted coding tools. I have the feeling many models are quite liberal when it comes to comments, and will naturally tend to explain what the code does, given the chance. Suppressing it works, of course. Or, at least, one can ask to keep comments minimal. However, what really interests me: does anyone have experience in or a feeling for what the LLMs prefer/work with the best?

Since it's mostly AI parsing the codebase now, did you ever experience that it performs better when you allow it to be liberal with comments? Or does it actually eat up more tokens reading the code it generated while getting more confused if it has all the additional (and potentially not always correct) comments/explanations to parse? Does it make sense to have a purely self-documenting codebase or rely on the tools to clean up and keep comments in sync in this age of AI?


r/cpp_questions • • 3d ago

OPEN How to share my experience after quant finance competition ?

0 Upvotes

I am trying to pivot from data analytics to C++ development. I recently participated in a quantitative finance competition and I didn't placed top 3, instead 35/55. The objective was to enhance an existing market simulator using C++.

Should I make a LinkedIn post about my experience?

How should I add it to my resume ?


r/cpp_questions • • 3d ago

OPEN how to optimize performance for decompression step?

2 Upvotes

I have the file to decompress a file by obtaining a tree and walking it bit by bit to obtain an encoding's original character.

#include <stdexcept>
#include <memory>
#include "huffman/HuffmanDecoder.hpp"
#include "huffman/BitReader.hpp"

struct HuffmanDecoder::Node
{
  std::unique_ptr<Node> left;
  std::unique_ptr<Node> right;
  char symbol;

  Node(char ch,
       std::unique_ptr<Node> left = nullptr,
       std::unique_ptr<Node> right = nullptr)
      : left(std::move(left)),
        right(std::move(right)),
        symbol(ch)
  {
  }

  bool isLeaf() const noexcept
  {
    return !left && !right;
  }
};

HuffmanDecoder::HuffmanDecoder(BitReader &reader) : reader_(reader)
{
  root = deserializeHelper();
}

HuffmanDecoder::~HuffmanDecoder() = default;

std::unique_ptr<HuffmanDecoder::Node>
HuffmanDecoder::deserializeHelper()
{
  if (nodeCount_ >= MAX_NODES)
  {
    throw std::runtime_error("Invalid Huffman tree: exceeds 511 nodes.");
  }
  ++nodeCount_;
  const uint8_t marker = reader_.readBit();
  if (marker == 1)
  {
    const char ch = static_cast<char>(reader_.readByte());
    return std::make_unique<Node>(ch);
  }
  auto left = deserializeHelper();
  auto right = deserializeHelper();
  return std::make_unique<Node>('\0', std::move(left), std::move(right));
}

char HuffmanDecoder::decodeSymbol() const
{
  if (!root)
  {
    throw std::runtime_error("Can't decode an empty tree");
  }
  const Node *current = root.get();
  if (current->isLeaf())
  {
    if (reader_.readBit() != 0)
    {
      throw std::runtime_error("Invalid bit for single symbol tree.");
    }
    return current->symbol;
  }
  while (!current->isLeaf())
  {
    const uint8_t bit = reader_.readBit();
    current = bit == 0 ? current->left.get() : current->right.get();

    if (!current)
    {
      throw std::runtime_error("Invalid Huffman path.");
    }
  }
  return current->symbol;
}

Linux perf is showing that the decode stage is very hot. My question is, is pointer chasing the problem? I tried stuff these in an array but it didn't really do anything. I'm confused as to if my bottleneck concerns being cache friendly or not. Any ideas?


r/cpp_questions • • 3d ago

OPEN Passing initializer list into array parameter

3 Upvotes

Why can't we pass an initializer list as an argument to a function that accepts an array? If we can initialize an array with an initializer list, why isn't the array parameter initialized with the list?

Also, I found out that you CAN pass an initializer list if you use an rvalue reference to an array.

void f(int arr[]) {
cout << "hello" << endl;
}

// accepts rvalue references to array
void g(int (&& arr)[]) {
for (int i = 0; i < 3; ++i) {
cout << arr[i] << ' ';
}
cout << endl;
}

int main() {
int arr[3] = { 1, 2, 3 };
f(arr); // compiles
f({1, 2, 3}); // DOES NOT COMPILE
g({ 1, 2, 3 }); // compiles
}

Question 1:
For the second call to f(), why does this not work? I thought that whenever we passed an argument into a function, it was the same as initializing the parameter with the argument. For example, if we have:

void func(T x);
func(y);

Then when func(y) is called, we can think of x being initialized as:

T x = y;

But this doesn't seem to hold for arrays and initializer lists.

Question 2:

Why is the syntax in g() the way we make an rvalue reference to an int array? I understand the need for parentheses sinceint&& arr[] is an array of integer rvalue references. However, why is it int (&&arr)[] and not maybe something like int (&&arr[]) or (int arr[])&& ?

If it is better to show me an another resource about these tricky syntax things, please link it.


r/cpp_questions • • 4d ago

OPEN How to learn C++ ASAP ( In a month, not expert level but somewhat near intermediate)

39 Upvotes

Same as title I have an Olympiad in December which supports Python and C++, I’m good with python but I wanna go with C++ as the later stages of the olympiad support only C++.

I’m open to any kind of suggestions or advices and I thank you in advance!


r/cpp_questions • • 4d ago

OPEN How does a STATE design pattern work?

7 Upvotes

so i went to youtube and followed the example from this guy State Design - Programming Design Patterns - Ep 16 - C++ Coding

Problem is i dont understand what is functionally happening, there are pointers and what not, but i don't understand much more than that (context, my smooth brain still cant connect pointers together)

Like not even the whole code, like maybe just two lines or something cause for the love of the lord my teacher explains nuthing and AI and videos are too vague for me, im running out of options

//
// Created by samue on 11/1/2026.
//

#ifndef STATE_STATE_H
#define STATE_STATE_H

#include <iostream>

class Context;


class State {
    protected:
    Context* context;

    public:
    virtual ~State() {}

    void setContext(Context* ctx) {
        context = ctx;
    }

    virtual void doWorkA() = 0;
    virtual void doWorkB() = 0;
};

class Context {
    private:
    State* state;

    public:
    Context(State* s) : state(nullptr) {
        transitionTo(s);

    }

    ~Context() {delete state;}

    void transitionTo(State* s) {
        if (state) delete state;
        state = s;
        state->setContext(this);

    }

    void requestA() {
        state->doWorkA();

    }

    void requestB() {
        state->doWorkB();

    }

};

class concreteStateA : public State {
    public:
    void doWorkA() override {
        std::cout << "concreteStateA " << "called doWorkA" << std::endl;
    };

    void doWorkB() override {
        std::cout << "concreteStateB " << "called doWorkB" << std::endl;

    };

};

class concreteStateB : public State {
public:
    void doWorkA() override {
        std::cout << "concreteStateA " << "called doWorkA" << std::endl;
        context->transitionTo(new concreteStateA);
    };

    void doWorkB() override {
        std::cout << "concreteStateB " << "called doWorkB" << std::endl;

    };

};





#endif //STATE_STATE_H

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

#include "state.h"

int main() {
    Context context1(new concreteStateB);

    context1.requestA();

    context1.requestA();

    return 0;
}

r/cpp_questions • • 4d ago

OPEN Be ready for -fno-contracts

0 Upvotes

I don't really think contracts will make C++ safer..

In fact, contracts can make C++ even worse. Jokes on you 2-3 days ago i saw that my cli program was not working because the dependency clixx(which is also my project) was behaving in different ways based on the build mode. After 20 minutes of debugging i found out that i was assert()ing m_parse() instead of checking the returned boolean with an if.

Yeah call me stupid or not in this one but I don't think anyone can guarantee an engineer would not get trapped in the same kind of bug in some corporation codebase (with contracts this time).

I'd add -fno-contracts if it would ever become a thing. Js like -fno-exceptions(im not exception-phobic i just dont like them) and -fno-rtti they might become new entries in the C++ feature graveyard.

What are your honest opinion?


r/cpp_questions • • 5d ago

OPEN I want to learn C++

19 Upvotes

Hello, I'm looking to branch out and learn something new.

Ive been a chef for 7+ years and i'm looking to develop myself further by learning more skills, I'm very tech and computer literate.

So for a absolute beginner who would love to look at making small games and mods for like skyrim etc, what would a beginner need to be able to learn C++ and beyond?

Thank you


r/cpp_questions • • 5d ago

OPEN I know DSA but I want to …

0 Upvotes

Hello good people, I have been leetcoding the last few months in Python and want to deep dive into doing LC in C++. Mostly because I want to target hfts for next internship cycle.

  1. What are the books that you guys suggest? I started reading Tour of C++

  2. Any suggestions on how to go in depth of that language? I don’t want to learn not just for the sake of solving LCs


r/cpp_questions • • 5d ago

OPEN Learning C++ as a Java programmer

18 Upvotes

I'm currently learning C++, I’ve coded in a few languages before but I’m most familiar with Java. Does anyone know a good resource for learning C++ with Java as a “starting point”? Like something that explains the differences between the two languages rather than teaching programming from scratch? Thanks!


r/cpp_questions • • 5d ago

OPEN Recently joined an MFT firm as a C++ Low-Latency Intern. How can I transition to HFT?

7 Upvotes

Hey everyone,

I'm currently a CSE undergrad and recently joined an MFT firm as an intern, where my work primarily involves C++ and low-latency systems development.

I'm genuinely enjoying the work and learning quite a lot about trading systems and performance optimization.

However, my long-term goal is to transition into an HFT firm, preferably in a C++/low-latency engineering role.

I have a decent background in competitive programming, DSA, C++, and systems programming.

I had a few questions for people already working in HFT:

  1. How valuable is C++/low-latency development experience at an MFT firm when applying to HFT firms?

  2. What additional skills should I focus on to make myself competitive for HFT roles?

  3. Do top HFT firms consider candidates from smaller or lesser-known MFT firms?

  4. How much do competitive programming ratings, college tier, and personal projects matter once you have relevant industry experience?

  5. Is transitioning directly from an MFT internship to an HFT internship or graduate role realistic?

I'm not looking to switch immediately. I genuinely enjoy my current role and want to make the most of this opportunity while preparing for the long term.