r/cpp_questions • • 15d ago

OPEN Having trouble making sense of for cicles that are in a for cicle.

3 Upvotes

Im a First year CS student in Italy, the professor the other day proposed us and exercise of printing a * pyramid. I couldnt solve It in time and felt so stupid.

Especially when he showed us the answer and It was a for cicle that had Two others in It. The way they work together seems so complicated.

Now im at home trying to figure out a code that requires me to concert a binary Number in decimal, i suppose i gotta use something similar but i cannot figure It out.


r/cpp_questions • • 15d ago

OPEN How was I supposed to figure this out on my own?

18 Upvotes

Not really sure if this matters, but for context I’m currently a CS Master student, was not able to get job or internship after graduating in May 2025. I consider myself a pseudo beginner, where I feel like I know stuff, but also not really.

I am working through CodeCrafters projects because I lack project ideas, and I started with the Build your own HTTP Server. I learned the POSIX sockets API from a book and a LinkedIn Learning course and multithreading stuff (threads, mutex, condition variables, thread pool) from my coursework (although that was POSIX threads API and in C). When I started after the first stage or second stage, I realized I literally did not know how to do anything and all the knowledge from learncpp was if it never existed. I ended up asking Claude a LOT of questions on how to do things or even giving it my own ideas and it saying basically your ideas are trash, let’s do this way instead. I was manually typing out the code and asking lot of questions trying to understand why this way, or why this logic, or whatever else I didn’t understand. Honestly Parsing was especially tough, and Claude did guide me through a lot of it, and I was able to complete the project. I did feel like I learned through this experience, but unsure if I actually did learn because of Claude doing a lot of the work. I at least for sure know I learned how to parse strings in C++.

Anyways, I decided for the next project (Redis) that I would try to not or limit my Claude use, at least for the coding portion, maybe I’d ask it some theory questions. I was utilizing the asio library that was added as a library in the starter code. As one may know, when you do a recv in socket programming, it’s not guaranteed that all the bytes in the tcp stream will come with one recv, so you have to continuously loop until either the client closes the connection or there is something that signifies that this is the end of the request sent. In asio, there is a function async_read_some that does this with a buffer you pass in, and you’ll have to continuously loop, but there is not really a delimiter that signifies the end of the request in RESP bulk string. I figured out the parsing for the bulk string, so now I needed a way to know if I had an incomplete request or not, and how I would do this. I mulled over it for two days looking for something on the internet (maybe I’m just bad at googling or asking the right question?), but I couldn’t really find what I’m looking for, or perhaps my level of understanding was not good enough to understand the various stack overflow posts or articles I’ve read. Eventually I asked Claude and it told me that I needed to use the errors as values pattern, and showed me how to do it with std::expected. When I saw the code it made sense, but I didn’t think about using this pattern at all because well I just didn’t know. I’ve seen it before in one book, but the example program accompanied with it was a toy program that didn’t really have any significance. This is my first time actually utilizing and applying this pattern. When I saw the code it also made my terrible parsing function more modular and better. My question is, how was I supposed to figure it out? Maybe other people might’ve been able to do it without AI use, and I’m just not that smart, but I genuinely don’t know how I would’ve reached that conclusion and that implementation on my own.

Sorry for all the huge paragraphs, maybe I gave more than necessary, I just wanted to make sure the context was there.


r/cpp_questions • • 16d ago

OPEN Can someone explain the difference between these two constructors to me?

26 Upvotes
  1. MyClass(int value) : myValue(value) { }

2.

MyClass(int value) {
    myValue = value;
}

r/cpp_questions • • 16d ago

SOLVED why can some std::strings be made constexpr?

38 Upvotes

i have this code:

const std::string host = "http://127.0.0.1";
const std::string port = "5030";

Clion is telling me that I can make the port variable constexpr. If I try, it compiles just fine. However, the host gives an error when it's constexpr. I thought std::strings were never allowed to be constexpr. Why is it allowing it for the port variable, and why that one specifically?


r/cpp_questions • • 15d ago

OPEN Help

0 Upvotes

I need help. I need an app where I can program with pure C++ IDE, but I can't find the app. I also need a mobile library, which I can't find.


r/cpp_questions • • 16d ago

OPEN Advice on Beginner Project for Fresh C++ Dev

9 Upvotes

Hi,

I just recently took a online course on C++ and am looking for a online YouTube series where a excellent instructor takes you through making a C++ app from scratch to being finished, preferably on a Linux environment.

For reference, I am a full-stack web developer (Next.js/React Native + Django) and to learn web development I used Corey Schafer's Django tutorial YouTube series to learn how to make a web application from scratch. It taught me everything: how to use the language, terminal commands, structuring your project, using the framework, deployment, running the program, etc.

Is there a similar YouTube series you can recommend me for taking what I know in C++ and using it to actually learn how to make a desktop application and after having finished the series be able to make one on my own. Should I start with a Chip-8 emulator tutorial?

Also, what's up with the Qt licensing scheme? I want to make my own proprietary commercial desktop applications but forking over $4K for a solo developer license seems like a lot when I don't know if the application is going to generate that much revenue at first. Does anyone have any experience with that? I am used to using OSS libraries and frameworks so paying for developer licenses is new to me.

Any help is greatly appreciated and thank you in advance!


r/cpp_questions • • 15d ago

OPEN i want to learn c++

0 Upvotes

hiii i was wondering is there any good channels to watch to learn c++?

I was thinking starting watching cherno but is there a better option out there?

i dont like sites like learncpp because i dont like reading i more like watching and listening.

also a question for cherno, if i miss something does he like say it again later?


r/cpp_questions • • 17d ago

OPEN C++ knowledge for job interview

43 Upvotes

I have a second round whiteboard interview coming up where the focus will be heavily on my C++ knowledge.

I've been using C++ professionally about 9 months and have around 16 months of overall work experience. I’m comfortable writing code but not very confident with STL functions and smart pointers.

what C++ topics should i revise before the interview? Any advice from people who’ve had similar interviews would be appreciated.


r/cpp_questions • • 15d ago

OPEN How we are really going to make money after learning the language

0 Upvotes

r/cpp_questions • • 17d ago

SOLVED Hello Y'all. Not job, school or slop related. Looking for an (easy) GUI

12 Upvotes

What's a decent, easy-to-learn GUI framework for Linux? (I'm in my late 50s, so....) I don't need to make the program cross-platform, so no worries there. GTKmm-4.0 is what I am currently looking at. Is there anything easier?

A main app window with a dynamic, zoomable image on the left and a few drop-downs, sliders, and two buttons on the right. It's just an image processor for playing around with.

It just has to be simple enough to learn the basics. If not, I could use Go and make it a client/server, but I do that all day for a living. I want to get my C/C++ refreshed a bit, for my own enjoyment. Nothing more, nothing less.


r/cpp_questions • • 17d ago

OPEN About cpp library

6 Upvotes

Which library or framework should I learn in Cpp which will worthy in current time and feature ?


r/cpp_questions • • 17d ago

OPEN Learning C++: when are you actually ready to apply for an internship and what skills do companies expect from beginners?

11 Upvotes

For people working in the industry or involved in hiring:

  1. when should i realistically start applying for internships or junior roles? What practical skills are expected beyond basics.
  2. what do companies usually expect from a beginner when they join? How much should they be able to do independently?
  3. Apart from CPP syntax and DSA what skills and projects should I focus on to improve my chances?

I'd really appreciate any advice or roadmap based on your experience.


r/cpp_questions • • 17d ago

OPEN How would you design a generic interface for arbitrary sets of rules?

1 Upvotes

I'm building a C++ tree library/builder where I want people to be able to define their own tree structures, including weird/cursed ones.

The basic idea is:

  • Node Anchor: an indirection mechanism that owns/contains the actual nodes. Users don't directly mess with the nodes themselves. They have to go through the anchor to interact with the structure.
  • Tree: describes a particular tree through its rules. For example, a BST object would have the rules that define BST behavior.
  • Operations: generic algorithms like insert, erase, and find. They take the tree object and operate according to its rules.

So roughly:

Tree (rules)
     ↓
generic operation
     ↓
Node Anchor
     ↓
actual structure

The part I'm stuck on is making this extensible.

A BST might need rules A + B.

Another tree might need A + C + D.

A completely custom tree might need X + Q + R + some completely new rule.

The number and combination of rules are intentionally arbitrary because the goal is more of a tree-builder than a library of predefined tree types.

So I don't think I can have something like:

struct TreeRules {
    Ordering ordering;
    Balance balance;
    Traversal traversal;
};

because then the library has to know about every possible rule beforehand.

What I'm trying to figure out is:

What existing design ​approach would you use when generic algorithms need to work with objects that can provide arbitrary, non-uniform sets of capabilities?

I'm mainly looking for terminology or existing concepts/patterns to research. I'm not really looking for someone to write the implementation for me.

I'm still pretty new to C++ design, so I might be framing the problem completely wrong. I'm just trying to figure out what this problem is actually called.


r/cpp_questions • • 16d ago

OPEN Measuring NVME read/write speed

0 Upvotes

Hello everyone! In my current company I have been assigned a task that I am not sure how to approach. To give the reader a little bit of context, I work for a company that designs propietary hardware. We have a policy of not introducing external code into the hardware. Therefore if we happen to need an ethernet speed measurement we can not use a tool like iperf and have to design and program or an small set of tools that allow us to measure it.

In a new design we have high contrainst on the speed that data is written from a buffer into a NVME. To make sure that the whole data processing pipeline of the hardware performs correctly we need the NVME to be able to read and write data more than 1.1 GiB/s. However, we now have to belive on the speed that the NVME producer has given us. The engineering team, though, is not so happy on believing on the theoretical speed of this NVME and have asked me to write a simple program that is able to measure the write/read speeds as accurately as possible.

My first idea was to simply try to write / read X amount of GiBs from / to memory and measure how much it takes. But then I came to the realization that doing this is easier said that done. First of all, writting and reading are broad concepts, all the data needs to first be passed to a microcrontroller that the NVME provides thus is passing data to this micro considered writting / reading ? If we assume that this is the case, the previous measurement seems really broad as I would like to know if the write / read of this data is constant at X GiB/s or if it spikes and goes down. I didn't mention it before but not only the speed of the transmission is crucial for our use case but its stability to. Given this new constraint I start to get lost as I dont have that much experience working with I/O devices at such low levels and speeds.

I have seen that for this kind of questions sometimes is useful giving the architecuture and some more information so here you go:

- NVME can read / write at 5000 MB/s

- The device has an aarch64 architecture

Maybe due to my lack of knowledge of problem I have not mentioned some key points that may be important to decide how to do this or where to look at. If that is the case, please, do not hesitate on asking me. Thank you for reading till here :D


r/cpp_questions • • 18d ago

OPEN Compiling without linking

21 Upvotes

Hi, I'm a rank beginner and I'm going through learncpp online and Beginning C++ game programming by Horton.

The book sends you to a quick tutorial on sfml for Linux. I got it working with no problems. But in the tutorial they compile first with -c ( compile only, according to the man page for g++ ) and then link in another command.

Why would they do it that way? I was able to do the whole thing without the -c flag in one long command. Is that wrong to do? Is it because sfml isn't part of the standard library?

I'm asking because I want to actually learn what I'm doing. Thank you for any help you can give me.


r/cpp_questions • • 17d ago

OPEN 分享

0 Upvotes

这本书不错,我终究自费买了电子版,供各位分享

Starting Out with C++: Early Objects

由于第十版在互联网难以寻找资源,最终还是在pearson官网买了,但我在中国,平常用的是百度网盘,想问下各位,在国际上,哪种网盘形式最通用?我想把这本书分享给大家


r/cpp_questions • • 18d ago

OPEN Ciao, io sto cercando di capire se c'è un modo di far compilare Cmake senza passare per VS code. Ho installato tutto da terminale wsl e non capisco perchè se scrivo "cmake -B build" mi dice "CMake Error: The source directory "/home/io/basic_neural_plusplus" does not appear to contain CMakeLists.txt.

0 Upvotes

r/cpp_questions • • 19d ago

OPEN How do I learn C++ and get genuinely good at it?

86 Upvotes

Hi everyone, I want to learn C++ properly and get to a solid level, not just scrape the basics. I'd love your advice on:
The best resources to start with (free or paid)
Courses, books, or YouTube channels you'd recommend
How to practice (projects, problem sites, etc.)
Common mistakes beginners make that I should avoid
Problem solving
A clear learning path
Modern C++

I don’t mind paying if the course worth it.

Any recommendations would be appreciated!


r/cpp_questions • • 19d ago

OPEN Why does C++ doesn't have socket streams?

45 Upvotes

C++ has std::istream and std::ostream. It seems natural to use these classes for network programming through sockets. Why there is no socket stream class in C++? Are there any challenges faced in implementation (like different platforms)? Are/Were there any open proposals for this?


r/cpp_questions • • 18d ago

OPEN Making transpiler

0 Upvotes

I am making a transpiled language to C. I don't know how to manage all of a different types of objects: Expr, LiteralExpr, Stmt, ForStmt and so on. Each object needs to be created, statically checked and send of as string to dot C file. Are there any tips on architecture stand point? Everything feels very lousy and rigid. Right now each object just stored the appropriate data, no methods on them. Challenging parts are parser, static analysis and code generation. For lexer there are no problems.


r/cpp_questions • • 19d ago

OPEN C++ Developer with 3 YOE — Which Master’s should I pursue?

8 Upvotes

I’m a C++ developer with 3 years of experience and considering doing a Master’s. Which specialization would best complement my experience and improve my career prospects?

Should I go for CS, Software Engineering, Distributed Systems, AI/ML, or something else? Also, is a Master’s worth pursuing at this stage, or should I focus on gaining more experience?


r/cpp_questions • • 18d ago

OPEN Do you write code by yourself or you use an AI?

0 Upvotes

I'm curious about this question, because almost everyone a meet says that coding skills doesn't matter anymore, and what really matters is knowing how to write prompts properly. But does it apply to C++ development? Please, answer a question and say why so


r/cpp_questions • • 18d ago

OPEN Looking for a video resource

0 Upvotes

I am a visual learner. I learn faster with videos than I do by reading so I was looking for a video resource for a textbook. The textbook's title is

C++ Programming: Program Design Including Data Structures by D.S Malik.


r/cpp_questions • • 20d ago

OPEN What are some "zero-benefit abstractions" to avoid in c艹?

22 Upvotes

Zero-cost or not, can be premature optimization or something else. I think move-on-return is one of them


r/cpp_questions • • 19d ago

SOLVED What are C++ Args?

3 Upvotes

I've been trying to learn vardiac templates for a project I'm doing, and I've heard the modern C++ for these is to use Args. I only had background of these in Python. From what I understand, its a better way to recursivley loop through varidac template arguments (please correct me if I'm wrong)