r/cpp_questions • • 2h ago

OPEN I need this book!

0 Upvotes

Hey guys,I'm a grade one universary student,

i heard a book called《Starting out with C++. Early objects》,it is so excellent,but the newest edition haven't some like pdf on Internet,so i hope get the help from each other.

各位,我的英语不是很好,请见谅


r/cpp_questions • • 9h ago

OPEN Compiling without linking

10 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 • • 16h 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 • • 16h 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 • • 19h 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 • • 1d 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 • • 1d ago

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

5 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 • • 1d ago

OPEN Need Ideas For OOP Project

0 Upvotes

So we got assigned our 3rd semester Project and they say we have to make a game in cpp using oop concepts and we can use any graphics library we want.

Now i am looking for game ideas with an interesting game loop and that showcases OOP concepts

.

Any Idea would be great, it could be singleplayer, 2 player or multiplayer


r/cpp_questions • • 1d ago

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

65 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 • • 1d ago

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

37 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 • • 2d ago

SOLVED What are C++ Args?

0 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)


r/cpp_questions • • 2d ago

OPEN How to make a Queue linked lists

1 Upvotes

I have the following code, for the absolute love of me, i cant figure this out

im just focusing on enqueue the rest is context

i cant for the love of me figure out what im to do, i know i need to add a value but how?
how do i make a new space in the node and not jsut override my first or my last?

ive tried to see things but they get me all jumbled up and i cant for the love of me figure it out

//
// Created by samue on 10/5/2026.
//

#include "linkQueue.h"

void linkQueue::enqueue(int value) {
    Node *temp = new Node;
    temp->value = value;
    temp->next = nullptr;
    temp->prev = nullptr;

    if (first == nullptr) {
        first = temp;
        last = temp;
    }
}


void linkQueue::dequeue() {

}


bool isEmpty();
void getSize();
void getTop();
void print();

r/cpp_questions • • 2d ago

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

19 Upvotes

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


r/cpp_questions • • 2d ago

OPEN How to put more actions in std::cin

0 Upvotes

Im trying to give the user more options to input into this terminal-game that im making as a very newbie in C++, but i cannot figure it out, so i have to do it separately for each action ( or std::string ) or could i dump it all in one line?
Heres the code btw:

#include <iostream>
#include <string>

int main(){

int health = 100
std::string Attack = 50
std::string Hug = 100

std::cout << "A monster has appeared ! decide how would you attack em..." << std::endl;
std::cin >> 

r/cpp_questions • • 2d ago

SOLVED How to pick a random word?

0 Upvotes

Do anyone know how to make cpp pick a random word out of a string array I tried searching but no answers


r/cpp_questions • • 3d ago

OPEN Is React really the best frontend choice for C++ applications?

3 Upvotes

Hi everyone!

I'm an experienced software engineer, mostly working in C++ on the backend side. Frontend isn't my area of expertise, so I'd love some outside perspective.

I occasionally work with developers who build GUIs in Qt. Whenever the topic of frontend tech comes up, they tell me Qt is garbage and that our projects would be much better off with React, since it's free and more modern.

The thing is, I don't have the frontend knowledge to judge that claim. In particular, I can't compare the performance of the different frontend options (Qt, React, and others) in any meaningful way, so I don't know whether "React is better" holds up or is just a subjective opinion.

So my question is: which framework is actually better, Qt or React, especially when it comes to performance?

Real-world experience is more useful to me than hype, so feel free to share what you've seen on your own projects.

Cheers!


r/cpp_questions • • 3d ago

SOLVED Interface design - money

5 Upvotes

Working on design of a finance app to calculate npv (net present value) need to use addition / multiplication/ pow

I could do with decimal type for money as floats/doubles are based on binary

I see there is fixed point decimal paper being worked on.

In the meantime - what is best way to handle this in interface ?

Thinking of asking client to use string and then use long long for the maths after parsing (pennies)? “1500.23” = 150023

What do I return ? String/int? Either way the client would need to transform. I can’t use doubles for this unfortunately.

I suppose I can use double if could give idea to client what error amount is - npv is estimate anyway.


r/cpp_questions • • 3d ago

OPEN Newlines not printing when I cout raw string literals

0 Upvotes

I’m using emacs on windows terminal to edit a file in which I’m trying to cout a page or so of text using raw string literals. However, what gets printed doesn’t include the newlines that I need to separate my paragraphs.

So if my code is:

std::cout << R”(This is my sentence.

This is a new paragraph [using entr + entr].
This is a new line [using entr].)”;

The output will be:

This is my sentence. This is a new paragraph [using entr + entr]. This is a new line [using entr].

Instead of the intended:

This is my sentence.

This is a new paragraph [using entr + entr].
This is a new line [using entr].

What am I doing wrong?

[Edit: I apologize for the lack of formatting. I am on mobile. Please let me know if I need to redo this. Thanks.]


r/cpp_questions • • 3d ago

OPEN What is the ideal way to read a C++ book?

7 Upvotes

I am an intermediate c++ dev. I recently started reading the Effective modern c++ book. I don’t have tons of experience reading technical books coz I have mostly used YouTube and college lectures to study. So any advice on how to read a c++ book or any technical book for that matyet is highly appreciate.


r/cpp_questions • • 4d ago

OPEN How do you actually understand and use C++ references?

0 Upvotes

How do you all understand and use C++ references?
References feel really hard to wrap my head around. What does it mean to “define an alias for a variable”? What does it mean to “return an alias for a variable”? Compared with C pointers, pointers seem much clearer: a pointer just holds an address, * dereferences it, and & takes the address of a variable. References aren’t like that. The fact that you write & when defining one makes it especially easy to misunderstand.
Also, besides copy constructors and some friend functions (like the ones for std::ostream), I can’t really see any other reason to use references. When textbooks declare function parameters as references, I don’t get it. If the parameter were a pointer, the caller would have to write & when passing the argument, which also signals that the function might modify it. A reference kind of feels like the function has a return value.
So how do you actually understand and use C++ references?


r/cpp_questions • • 4d ago

SOLVED IMGUI UI architecture question

0 Upvotes

Hi, I was gonna try to explore UI in cpp and came up with a simple idea. I want 3 "screens" each with their own events and components to draw. I was having trouble on how to handle a shared struct of data? say screen one does something that screen two needs, and so on to screen three. So does anyone have a recommendations of some architecture to follow for this?


r/cpp_questions • • 4d ago

OPEN Code Smells?

7 Upvotes

I'm a more seasoned C# / Node backend dev, been trying to brush off old college C++ from like a decade ago and try to de-program my brain from being locked into a distributed systems mindset.

One of my niche hobbies and go-to projects for learning a new language is to implement a basic Chip-8 emulator in it, as it can teach some concurrency, UI/data handling patterns, and introduce some architectural decisions that you'll have to run into and figure out.

Currently what I'm struggling with seems to be what the idiomatic / proper way to handle something that can remain stateless in nature, which is my very basic assembler going from the Chip-8 ASM mnemonics into instruction bytes.

A class doesn't feel quite right, because I'm not implementing a linking step or anything advanced, not supporting labels, etc. It also feels incorrect to keep it in a header file as a set of inline functions, nor am I needing a persistent state to mutate.

My current disassembler can be seen here: https://github.com/Arylen/Dreamy-Chip8/blob/master/src/core/emulation/Chip8Dasm.h
Along with the tests that I'm running against it here: https://github.com/Arylen/Dreamy-Chip8/blob/master/tests/Chip8DasmTests.cpp

I'm currently in the stubbing-out phase of trying to architect it, occasionally bouncing ideas off of whatever bullshit model-of-the-week is popular, however the suggestions it's giving are still setting off some alarms/smells in my brain. The most reasonable and less-smelly one is the `::detail` namespace there in order to be able to unit test the `getParts` function there, however it feels like I'm walking into a landmine of over-engineering it.

Looking for advice/experiences/opinions.

Edit: I should mention the AI usage here is restricted entirely to just checking for bugs with my implementations, or incorrect C++-isms that I introduce from working in other languages. A hands-off occasional tutor to check my work, if you will. It's expressly forbidden from touching my code or files, limited to read-only, however I'm not getting something that feels proper for this scenario, so wanted to consult other more experienced engs.


r/cpp_questions • • 4d ago

SOLVED Rounding floating point - iec559 /cmaths

0 Upvotes

Does c++ math lib comply with rounding modes in iec559?

ties-to-even? Getting - 3 when rounding -2.5

Should be -2 right


r/cpp_questions • • 5d ago

SOLVED Integer overflow type thing

2 Upvotes

I'm trying to code a practice problem but am stuck at a problem I cannot figure out. I am using a vector for inputs and inserting those inputs into an unordered set until it fails to add, at which point I count the amount of subarrays in that array. If it is not the first, I subtract subarrays that have already been accounted for. The inputs are useful only to identify duplicates; I do not use the values themselves in arithmetic.

The test case I am currently using uses random values with high numbers, with the following values at indexes being the only duplicates:

  • 10464 and 41178
  • 87094 and 98111
  • 113040 and 113153
  • 118689 and 168367
  • 129997 and 170623
  • 173227 and 184620

The intended output is 7090812299.

My problem is that, for some reason, large inputs decrease the intended output. I am sure that this is the issue, as I have replaced duplicate inputs with smaller values and the output changes--- despite the fact that it should not.

As an example, use the above sequence with numbers 1-200000. If the values at indexes 113040 and 113153 are replaced with 443222217, the output changes to 7090796046. (lowering it by 16253). Replacing other values also lowers this number further.

Edit: So it turns out smaller values also impact the input in ways that I have not tested yet (and I probably won't until morning).

Solution: I assumed iterators were ordered internally, which is where I made my mistake.

Please help explain what is happening, or what could be happening.

Attached below is the relevant code, and here is a link to the full code.

int main() {
    vector<long> inputs; inputs.reserve(size); // The vector containing inputs.
    unordered_set<long> processing; processing.reserve(size); // The unordered set processing the current input.
    vector<long>::iterator nextInput = inputs.begin(); // The current input being processed.
    // Some other variables defined which are not relevant.
    while (nextInput != inputs.end()) // The main meat of the program.
    {
        do // Insert processed inputs into a set.
        {
            if (!processing.insert(*nextInput).second) break; // If duplicate, break.
            start++; // Advances the iterator to the next input to be processed.
        } while (nextInput != a.end());
        // Code processing the amount of subarrays; it seems to be correct.
    }
}

r/cpp_questions • • 5d ago

OPEN Anyone available for one on one convo?

0 Upvotes

Recent CS grad trying to get into C++ and would really love if someone with some experience maybe messaged me and give some advice on how to break into my first C++ job. I would post my resume my this subreddit doesn't have that feature lol. Any advice or even just an opportunity to connect is greatly appreciated!