r/cpp_questions • • Jul 17 '26

OPEN Are LLM’s REALLY a good teachers?

0 Upvotes

I use LLM’s to learn fundamentals and programming libraries like Raylib and SDL3. However, some guy on youtube said something that I never really thought of:

“AI will show you how to do something in the worst way possible.”

For someone looking to ACTUALLY be competent in C++, should I avoid learning with LLM’s? Will LLM learning keep me average?


r/cpp_questions • • Jul 04 '20

META Banning posts about books and online ressources

6 Upvotes

Would it be possible to ban questions asking for books and online ressources? These threads appear on a daily base. A quick search (in this sub) would reveal so many answers for them from other users. Its quite unnessecary to answer this exact question again and again. We could also make a sticky post where we can collect them.


r/cpp_questions • • Sep 09 '26

OPEN I want to understand constexpr

0 Upvotes

i want to understand constexpr can somebody make it a bit easier to understand


r/cpp_questions • • Aug 04 '26

OPEN Whats the funniest joke u heard in c++

2 Upvotes

r/cpp_questions • • May 13 '26

SOLVED Bug in GCC or is Claude lying to me?

0 Upvotes

Hi everyone! I found something interesting in c++ which not even Claude, Gemini or ChatGPT can answer!

Why would the following code not compile? (GCC, C++23)

#include <iostream>

template <double D>
void print()
{
  std::cout << D << '\n';
}

int main()
{
  print<0.0f>();

  std::cout << "Done!\n";
  return 0;
}

Here is the error message:

src/main.cpp: In function ‘int main()’:
src/main.cpp:11:16: error: no matching function for call to ‘print<0.0f>()’
   11 |     print<0.0f>();
      |     ~~~~~~~~~~~^~
src/main.cpp:11:16: note: there is 1 candidate
src/main.cpp:4:6: note: candidate 1: ‘template<double D> void print()’
    4 | void print()
      |      ^~~~~
src/main.cpp:4:6: note: template argument deduction/substitution failed:
src/main.cpp:11:16: error: conversion from ‘float’ to ‘double’ in a converted constant expression
   11 |     print<0.0f>();
      |     ~~~~~~~~~~~^~
src/main.cpp:11:16: error: could not convert ‘0.0f’ from ‘float’ to ‘double’
   11 |     print<0.0f>();
      |     ~~~~~~~~~~~^~
      |                |
      |                float
make: *** [Makefile:116: src/main.o] Error 1

In the cpp standard it says that implicit floating-point promotion is allowed with constexpr values, check it out here, under the "Converted constant expression" section https://en.cppreference.com/cpp/language/constant_expression

Claude keeps saying that this is a bug in GCC

So I'm really excited to know whats actually going on!

Thank you everyone in advance!


r/cpp_questions • • Jul 17 '26

SOLVED Could you please recommend some good resources on how to create a modern C++ setup? (I want a strictly terminal setup. No IDE click a button magic)

1 Upvotes

Greetings everyone. I've been learning C++ using just single file programs and a simple Makefile setup.

I'm on Arch Linux and I'm using the clang package. So clangd for language support, and clang-format.

I don't know why but it seems like many courses seem to skip the project setup and focus more on setting up VS Code (which I don't use), or directing you to some online IDE, or some obscure editor.

I just want to be able to setup my C++ project from the terminal and not add anything to my config files unless I know why each line is there.

I'm looking for a resource that focuses on this specific part of C++.


r/cpp_questions • • Nov 21 '23

OPEN the future of c/c++ with rust

2 Upvotes

I am a systems programmer. Will rust replace c++ in systems programming?

They've been saying that Rust will replace C++ for decades, but are there any concrete examples?

moreover, how will we replace the many system libraries and products that have already been created?


r/cpp_questions • • Sep 24 '24

OPEN C++ as first programming language.

2 Upvotes

Hey guys! So i was wondering if its even possible to leaen cpp as ur first programming language or not? I know the python basics but not morw. Id like to hear yalls opinions


r/cpp_questions • • May 04 '25

OPEN Help me understand "stack" vs "heap" concept

0 Upvotes

Every time I try to learn about the "stack vs heap" concept I keep hearing the same nonsense:

"In stack there are only two options: push and pop. You can't access anything in between or from an arbitrary place".

But this is not true! I can access anything from the stack: "mov eax,[esp+13]". Why do they keep saying that?


r/cpp_questions • • 22d ago

OPEN HOW can I replace win's 'windows.h' in Linux

3 Upvotes

as title


r/cpp_questions • • Dec 20 '25

OPEN Want to learn C++. Suggestions needed for the right approach to learn.

0 Upvotes

So, hello guys. I am an 18 y/o college student who is trying to learn C++ for the sole purpose of learning and making games. In the past I used varoius game engines like Unity, Godot, GameMaker, etc and loved making games inside each of them. But, I felt somewhat unsatisfied using them as I also want to learn how to do programming while still learning game development. So I think C++ seems like a good option for me. I don't have much experience in programming as I only learned python (a while back) and a little bit of C. So if anybody can help/guide me how to start learning C++ in order to make some cool games, it would really help me a lot :) Like please mention the resources/tutorials and approach to learn this language. P. S - Couldn't use Unreal Engine as my system is too underpowered for that🥲


r/cpp_questions • • Feb 23 '25

OPEN Is there anything wrong with using cpp as c?

0 Upvotes

I like having a standard library (wouldn’t mind making my own library I have full control over), I like classes, and I like templates when I use them. So I do like barebones c++98 features I suppose. However, stuff like smart pointers, all the different keywords (besides native c ones, and new and delete), and basically everything “super fancy” cpp has to offer I don’t really enjoy. I just find myself spending a bit of time trying to figure out if I am using the language properly rather than just going with what I know for sure is correct.

C would honestly be perfect for me, but I just enjoy the class architecture that c++ offers, too much. I’m not sure if there is a way at all possible, through some library or something, to implement classes in c, but it would be cool.

Also could you imagine a programming language called C+. It’s literally just c with classes, and a very very very small standard library that maybe has a couple data structures, and ability to use new and delete rather than malloc or whatever.


r/cpp_questions • • Jul 08 '25

OPEN Do i really need to study the entirety of c++ to join game development?

4 Upvotes

It’s been confusing for me as of what to learn. Should i just learn the basics or something else?


r/cpp_questions • • Apr 23 '26

OPEN How to start C++

4 Upvotes

Basically im in school and they use visuals studio code. I only have a laptop and no idea of Programming honestly. Should i install Linux? Probably a program clichee to ask this haha


r/cpp_questions • • Jan 31 '26

OPEN How to use pointers in C++ ?

0 Upvotes

I'm actually a Java developer and I'm confusedabout pointers like how are they needed like in this code Google gave me:

#include <iostream>
#include <memory> // Required for smart pointers

int main() {
    // 1. Declare and initialize a variable
    int var = 20;

    // 2. Declare a pointer and assign the address of 'var'
    int* ptr = &var;

    // 3. Access and manipulate the value using the pointer
    std::cout << "Value of var: " << var << std::endl;
    std::cout << "Address stored in ptr: " << ptr << std::endl;
    std::cout << "Value at address in ptr: " << *ptr << std::endl;

    // 4. Change the value via the pointer
    *ptr = 30;
    std::cout << "New value of var: " << var << std::endl;

    return 0;
}

how to use them


r/cpp_questions • • Apr 26 '22

OPEN Is using emacs just a circle jerk?

0 Upvotes

Or am i using it wrong? I like gnu philosophy&environment but IDEs look like more practical. But i want to see experienced guys' opinions anyway.


r/cpp_questions • • Nov 25 '25

SOLVED How to call std::visit where the visitor is a variant?

0 Upvotes

Even AI can't make this code compile. (Just starts hallucinating). How do I alter the code to avoid a compiler error at the last line (indicated by comment.)

#include <iostream>
#include <iomanip>
#include <variant>
#include <string>
#include <cstdlib>

using Element = std::variant<char, int, float>;

struct decVisitor
{
    template<typename T>
    void operator()(T a){        
        std::cout << std::dec << a << "\n";
    }
};

struct hexVisitor
{
    template<typename T>
    void operator()(T a){        
        std::cout << std::hex << a << "\n";
    }
};

using FormatVisitor = std::variant<decVisitor, hexVisitor>;

int main()
{
    Element a = 255;
    FormatVisitor eitherVisitor = decVisitor{};
    if(rand() % 2){
        eitherVisitor = hexVisitor{};
    }
    std::visit(decVisitor{}, a); // good.
    std::visit(hexVisitor{}, a); // good.
    
    std::visit(eitherVisitor, a); // Does not compile. 
}

r/cpp_questions • • Apr 07 '26

OPEN std::vector<std::mutex> helper_mutexes{}; seems to not protect std::vector<bool> tasks_available; GPT gives me an answer but I want to verify it here.

0 Upvotes

I considered myself relatively experienced with C++ now, especially with synchronization and concurrency control, but I recently faced a bug that makes me crazy. Basically, I want to use a vector of boolean to control helper threads execution where each helper thread's condition variable, task status, tasks, etc. are protected by a mutex. I thought it was safe. However, there are occassions where a certain thread observes the task avaialble being true despite it shouldn't be. Consulting GPT,

std::vector<bool> is not a normal vector<T>. It packs bits together, so different indices may live in the same machine word. Accessing tasks_available[i] is really a proxy read-modify-write on that packed word, not an ordinary independent bool&.
...
Yes — that is actually very plausible, and the reason is that with std::vector<bool>, they are not really treated as independent normal variables.

std::vector<bool> is a special packed representation. Instead of storing one full byte per element, it stores many boolean values as bits inside the same word/byte block.

Was GPT correct? I knew the things about words and cache coherence, but I thought C++ supports variables smaller than a single word, e.g., 4 byte integers and floats. From my udnerstanding, these 4 bytes integers do not face the same issues. In fact, my bug was resolved by changing bool into size_t (which is 8 bytes though).


r/cpp_questions • • Aug 31 '25

OPEN What is long long

1 Upvotes

I saw some c++ code and I noticed it has long long, I never knew you could put 2 primitives next to each other. What does this do?


r/cpp_questions • • Feb 18 '25

SOLVED Point of Polymorphism

1 Upvotes

This feels like a dumb question but what is the point of polymorphism?

Why would you write the function in the parent class if you have to rewrite it later in the child class it seems like extra code that serves no purpose.


r/cpp_questions • • Dec 03 '25

OPEN The fear of heap

1 Upvotes

Hi, 4th year CS student here, also working part-time in computer vision with C++, heavily OpenCV based.

Im always having concerns while using heap because i think it hurts performance not only during allocation, but also while read/write operations too.

The story is i've made a benchmark to one of my applications using stack alloc, raw pointer with new, and with smart pointers. It was an app that reads your camera and shows it in terminal window using ASCII, nothing too crazy. But the results did affect me a lot.

(Note that image buffer data handled by opencv internally and heap allocated. Following pointers are belong to objects that holds a ref to image buffer)

  • Stack alloc and passing objects via ref(&) or raw ptr was the fastest method. I could render like 8 camera views at 30fps.

  • Next was the heap allocation via new. It was drastically slower, i was barely rendering 6 cameras at 30fps

  • The uniuqe ptr is almost no difference while shared ptr did like 5 cameras.

This experiment traumatized me about heap memory. Why just accesing a pointer has that much difference between stack and heap?

My guts screaming at me that there should be no difference because they would be most likely cached, even if not reading a ptr from heap or stack should not matter, just few cpu cycles. But the experiment shows otherwise. Please help me understand this.


r/cpp_questions • • Jul 17 '25

OPEN Question about std:string

3 Upvotes

So I have been learning C++ for the past 4 years through HS and Uni and before that I did C for 3 years. My question is why do people use ‘std::string’ when you can just make a string through . Are there methods that only work on std::strings or is there a reason why people use std::string. because it has aways been confusing to me, because every-time I type std::string my mind just wonders why I don’t just use a array of char. I have been to embarrassed to ask my Prof so I decided to post here.


r/cpp_questions • • Apr 30 '26

OPEN How do I seriously learn C++ without relying too much on AI?

3 Upvotes

I want to actually get serious about learning C++ instead of constantly leaning on AI to explain things, fix errors, or write code for me.

For context, I’m mainly interested in graphics programming and engine development. AI has helped me get unstuck a lot, but lately I’ve started feeling like I’m relying on it too much. I don’t want to end up only being able to build things when AI is walking me through every step. I want to actually understand the language, the standard library, and the code I’m writing.

Right now my plan is to go through LearnCpp properly and start using cppreference more often. My issue with cppreference is that it can feel really dense, especially when I don’t already know exactly what I’m looking for.

For people who learned C++ seriously, how would you approach this?

Should I go through LearnCpp linearly and take notes, or is there a better way?

Should I write small examples for every concept before moving on?

How should I use cppreference without getting overwhelmed?

When reading cppreference, what sections are worth focusing on early, and what should I ignore until later?

How do I build the habit of debugging compiler errors, template errors, and linker errors myself before asking AI?

For graphics programming specifically, what C++ topics should I prioritize after the basics? I already understand things like opening a window with SDL and getting a simple graphics project running, but I want to know what parts of C++ matter most as I go deeper into engine and rendering work.

I’d appreciate any practical advice, especially around learning habits, reading documentation, and getting better at solving problems on my own before immediately reaching for AI.


r/cpp_questions • • Jun 13 '26

OPEN Is there any mobile C++ IDE?

2 Upvotes

Because of my lifestyle where i travel quite much and ending up at home very lately, I'm very interrested in finding a mobile IDE for C++. So, is there any good and fast mobile IDE for C++ that won't explode my samsung Galaxy A07 (I know that there are laptops existing but I can't access them rn)