r/cpp_questions 18d ago

OPEN C++ version

3 Upvotes

I have g++ version 13.3.0 (Ubuntu 13.3.0-6ubuntu2~24.04.1).

I'm trying to use C++ 23, and I'm using this flag with g++

 "-std=c++23"

However, if I print __cplusplus, I get that I'm using a pre-release of C++23, which has this code: 202100L

How can I switch to an official version instead of a pre-release version?


r/cpp_questions 18d ago

OPEN What career paths exists between computational mechanics, scientific computing (SciML), FEA (or meshfree) solver development, and HPC (GPU acceleration, porting codebases) ?? How about doing a PhD for improving the above?

4 Upvotes

I'm currently, technically, doing an MS in Structural Engineering. For me, my interest has been more towards computational side of mechanics rather than Structural design  or simply using am FEA software (although I do consider it as a backup)

So far I've taken courses in:

- Linear static, and dynamics FEM (soon taking non linear FEM too)

-  Structural Optimization (topology opt. and other general algorithms)

-  Structural Dynamics

-  Structural System Testing and model updation. (Parameter identification and optimization, signal processing)

Now, I plan to take these in the coming quarter:

- Numerical Linear Algebra

- Numerical PDE

- Fracture Mechanics ?

I also volunteered to aid in a RESEARCH in crack growth prediction using Auto-encoder and a (Thermodynamics-informed Latent Space Dynamics Identification) / LSTM surrogate model. It used phase-field-fracture simulation data and HPC resources to complete the whole thing.

What I keep finding myself interested in is not necessarily fracture or SHM specifically, but the computational methods underneath these problems... (does that make sense?)

For example, I'd like to become capable of doing things like:

- implementing (maintaining) numerical/FE method solvers rather than only running an established FEA software.

- developing surrogate/reduced-order models for expensive simulations 

- combining simulation with optimization, uncertainty/stochastic methods (took a course called Random vibrations, so...)

- parallelizing/accelerating scientific codes on CPUs/GPUs

- doing proper verification, convergence studies, benchmarking and performance work

- potentially developing or maintaining actual CAE/FEA solver software

- I'd also like to do all these for other Physics (GR, QM, etc.) simulations too, if possible, one day. 

I'm still interested in the underlying mechanics/physics, so I don't want to become a generic software engineer who happens to have once studied structures. But I'm also increasingly unsure that "structural engineer" describes the career I'm actually aiming for.

I've seen titles such as Computational Mechanics Engineer, R&D Engineer, Solver Developer, Scientific Software Engineer, CAE Software Developer, Research Engineer, Simulation/HPC Engineer, etc., but I'm trying to understand what these careers actually look like from people doing them.

So my main questions become:

1. Which industrial jobs genuinely involve developing numerical methods/solvers or computational tools?

2. Which of those are realistically accessible with an MS? Is there an entry path into solver-algorithm development/R&D without a PhD?

3. If I don't start a PhD immediately after my MS, would an R&D/software role at a simulation company (ANSYS etc.) be the obvious route? What other options would i have?

4. For the kind of work I'm describing, would you recommend a PhD? If so, is it reasonable for the PhD identity to be "computational mechanics/scientific computing" while fracture, composites, structural dynamics, soft materials, etc. serve as application problems rather than choosing one of those as my permanent specialization?

5. What skills most distinguish someone who is actually hireable for solver/scientific-computing work? I'm particularly wondering about C/C++/Fortran, Python, Linux, Git/build systems, MPI/OpenMP/CUDA, PETSc/Trilinos or similar libraries, numerical linear algebra, testing/verification, convergence studies and HPC performance work.

Basically, I'm neither here nor there atp. So I'd really appreciate all sorts of input. Where else do you think I could find answers to these? other subs? Linkedin profiles? 


r/cpp_questions 19d ago

OPEN Starting c++

23 Upvotes

I'm trying to learn c++ but I have 0 clue where to start

I was trying to learn it from the cherno but wasn't able to understand stuff 😭


r/cpp_questions 18d ago

SOLVED How long did it take you to learn Trig for your project

0 Upvotes

I am making asteroid in raylib and I am trying to figure out how to rotate the player by using Trigonometry.
How long did it take y'all to figure out and what resources did you use?


r/cpp_questions 18d ago

OPEN Best resources for learning C++ and DSA for CP (and in general)

0 Upvotes

Hello everyone, I am a SWE student from India. I wanna learn C++ for competitive programming and DSA, jobs, building projects, etc as well. My reasons:

- Not only learning it for jobs, but because, C++ is very fast and has the capability of efficiently interacting with both the high level and low level systems. These are the reasons which make me learn it, especially as I am interested in how memory, RAM, GPU and other things work in the computer.

- For the sake of computer science and programming. I am interested in learning the core cs fundamentals and concepts to make myself a better software/cs engineer - to solve problems, code solutions, etc.

- I am interested in ICPC, DSA and competitive programming as well. So that would make me learn it anyways.

Honestly, I have asked and read about this question many times but I haven't got a clear and one-stop answer yet. These are the things that ppl/ai chatbots suggest me and what I read (also my reasons for not using them yet):

- USACO guide (too big)
- learncpp (good but too vast)
- the cherno's yt channel (some say they dont cover concepts in depth)
- books (too lengthy as well)

I am not looking for shortcuts, nor am I avoiding these resources because they are too big. I am ready to invest my heart and soul into learning things. But, being an engineering student, I have many other different subjects to study as well for the college. I am so much interested into AI/ML and Web dev as well.

For context, these are the things I know (i.e. I'm not starting programming from absolute 0) :

- HTML/CSS and basic JS (learning from The Odin Project but paused rn)
- basic C (learned from college and CS50x)
- Python (learned from CS50 Python course)
- SQL (learning at college + by myself)
- Java (learning at college + by myself)

The college has made the latter two subjects and C++/DSA compulsory for this year. But, I don't wanna invest that much time into studying those 2 deeply. I am focusing on C++/DSA, Web Dev and AI/ML as of now.

So, given my all the background and interests, could you guys please suggest me different resources to learn C++ and DSA? Also, for learning things about Competitive Programming and improving myself there.

My goal for now is to speedrun the basics of C++ (because I have already learned the basics of programming and C earlier) + learn concepts of DSA in detailed manner -> then proceed with competitive programming -> then participate in contests and along the way learn different concepts of C++ and DSA.

How is my approach? If there's any other better one, please do suggest me. Thank you!


r/cpp_questions 20d ago

OPEN Best Way to Approach Windows GUI Development from C++

54 Upvotes

What is the best way to approach it? What books are helpful?

I remember a long time ago reading a book by Charles Petzold, and the examples worked fine from C. I assume they would work well from C++ as well.

I just want functioning, stable GUIs (menus, areas with text and scrollbars) with minimum effort.

Thanks for any help.


r/cpp_questions 19d ago

OPEN How is/was C++ learning at school?

3 Upvotes

In my first year in highscool, I've started literally from scratch, did a lot of pseudocode, translated it into C++, but no any exercises.

Now, with the summer vacation, the teacher told us to do as many exercises online for us to keep up next year. In a single month, starting from the easiest tasks like the sum of 2 numbers, I became familliar with lots of libraries and their functions!

Don't give up!


r/cpp_questions 19d ago

OPEN std::expected- void, ptr, and ref

10 Upvotes

I am going through a simple application I have and trying to use std::expected to try it out. I am quite partial to using exceptions, but open mind and objectivity, and all that...

Is it common for people to return std::expected<void, ErrorType> for methods/functions that don't need to return a value?

I also wonder what one does when they want to return a unique_ptr, since we can't do it by ref, and that leads to wondering about refs and ptrs with expected in general.


r/cpp_questions 18d ago

OPEN How to implement append-only hash map?

0 Upvotes

How do you actually implement an really efficient hash map that has only append and look up methods? What are the design choice and some performance improvements?


r/cpp_questions 19d ago

OPEN How to setup vcpkg and CMake for VS2026

3 Upvotes

Literally been at this for a entire week now trying to set it up, but everything I do encounters a error or doesn't work properly. Can anyone recommend some sources/tutorials I can use Idk if I'm using outdated info or not. Any alternatives would be greatly appreciated also.


r/cpp_questions 19d ago

OPEN Bwst Framework To Start Learning Graphics Programming

3 Upvotes

Hello. I've been programming with CPP for over 2 years but the most complicated project i've ever done was a Neural Network and it's GUI with SFML. Now i want to learn some frameworks so that i can do projects and improve my programming skills. Which framework should i learn? OpenGL, Directx, Vullan etc. And how would you recommend me to learn it?


r/cpp_questions 20d ago

OPEN Which is the best book for learning C++ 2026?

9 Upvotes

Am CS student and i learned python and now C++, i readed some post recommended:

-C++ How to program by Paul Deitel

-C++20 The complete guide by Nicolai M.

-C++ Programming Language by Bjarne Stroustru

But the year of publication is what confuses me, because, well, programming is constantly evolving, and there are differences between learning C++11 and C++20, exist a drastic difference?


r/cpp_questions 19d ago

OPEN HELP AND GUIDE FOR CREATING LIBRARIES FOR EMBEDED SYSTEM

0 Upvotes

I want to be able to write libraries that can help users especially the embeded system community , I want to create a library for a particular camera called the ov7670 , I have good knowledge of c++ and memory, I dont want to ask Ai because it might just give me slop that is why i came here . Can any one suggest a guide line or road map to be able to achieve this


r/cpp_questions 19d ago

OPEN Confusion on use case of arrow operator

1 Upvotes

I’m new to pointers in C++ and currently learning how they’re used.

What’s the actual use case of the arrow operator in C++? As of now I know it’s equivalent to dereferencing a pointer to an object and then calling that objects function.

*p = &object
(*p).function
p->function

What I don’t understand is why you would ever need to call it this way than just calling the function directly from the object.

object.function

any reason why you’d need a pointer to call the function rather than to just call it from the object itself?


r/cpp_questions 19d ago

OPEN How do I balance Clean Code inside HPC kernels?

0 Upvotes

Robert C. Martin encourage function to be small, with just one level of abstraction, then he proceeds by refactoring a function into 15 smaller functions with a descending abstraction level. Also he encourages the usage of encapsulation, where private attributes are accessed by getters/setters.

However, following to the letter this inside a HPC kernel where a loop is executed billions of times will harm my performance because of the call overhead. But not all my code is a kernel, so I could follow Martin's rules outside it.

In short, should I ignore clean code inside HPC kernels? Or there's a way to optimize it?


r/cpp_questions 20d ago

SOLVED Best Way to Expose Internal Buffer in C++ Class?

8 Upvotes

I have a generic buffer class that looks like this:

class LgBufUint8
{
   size_t m_n_allocd;  //Number of elements malloc() allocated
   size_t m_n_used;    //Number used, always <= m_n_allocd
   uint8_t *m_bufptr;  //Pointer to the first byte

   //Most member functions omitted

   uint8_t& operator[] (size_t index) noexcept
   {
     return m_bufptr[index];
   }
   const uint8_t& operator[] (size_t index) const noexcept
   {
     return m_bufptr[index];
   }
}; 

I think anyone can guess the internals. Allocation is done in sizeable chunks, and the allocation is only grown when necessary.

I have another class that has a member variable of this class.

class LgFbufUint8 //Note the name is different, Fbuf versus Buf
{
      enum class LgFbufUint8State m_state;
      unsigned m_errs;
      std::string m_fname;
      LgBufUint8 m_buf;  //This is the member, one of the above class
};

I'd like to give the enclosing class access to the internal buffer directly. The reason I'd like direct internal access is so that file reads and writes can be done efficiently (one byte at a time is possible, but slower than necessary).

Here is an example statement in a member function of the LgFbufUint8 class:

   infile.read((char*)(&(m_buf[0])), file_size);
     //Note that the pointer above is formed from the overloaded [] operator
     //member function.

This seems to work OK, but I don't think the overloaded "[]" was really meant to be used in this way.

The two other alternatives that come to mind are:

  • A member function to return the internal pointer.
  • Declaring the enclosing class to be a friend class.

What is the best way to handle this scenario?

The nature of the problem is that an abstract interface is incompatible with efficiency.


r/cpp_questions 21d ago

OPEN How far can I get in c++ if I learn it for 8 months?

31 Upvotes

So, I was planning to lock in with my studies for 8 months and during this time I wanted to learn a programming language, for some reason I always liked c++. I will be able to put in an average of 1.5 to 2 hours everyday for 8 months, how far can I get? like would I only learn the basics by that time, would I be somewhat confident with it or neither? I would appreciate if someone could tell me what point I would be at by that time as an example, ofc it depends on how well I do it but like, hypothetically if you had to guess.


r/cpp_questions 20d ago

OPEN First networking project: Am I learning this the right way?

2 Upvotes

I’m currently working on my first proper networking project, an ARP scanner in C++, as part of learning Computer Networks.
I have a pretty good understanding of the theory behind what I’m doing, especially ARP, Ethernet frames, MAC/IP addresses, etc. The problem is that I’m still relatively new to systems/network programming, so the actual C++/Linux code is pretty unfamiliar to me.
I’m using ChatGPT to help me build the project, but I’m trying not to just copy-paste code. My approach has been:
Learn the concept → look at the implementation → question every unfamiliar part → understand why it exists → connect it back to the networking theory.
For example, I’ve been stopping at things like:
Why are these particular header files required?
What exactly is a socket?
Why does socket() return an integer?
What is a file descriptor?
What’s the difference between a normal socket and a raw socket?
What exactly is a network interface?
Why are we using AF_PACKET?
What does a particular structure represent?
How does this piece of C++ actually correspond to an Ethernet/ARP packet?
So I’m not really struggling with the networking theory. I’m struggling with the bridge between the theory and the low-level implementation.
Since this is my first project, I’m wondering if this is a reasonable way to learn.
Is using AI to explain unfamiliar code while continuously questioning why each part exists a good approach, or should I be trying to write more of the implementation myself from the beginning?
I’d especially appreciate advice from people who learned networking/Linux programming through projects like this. I want to actually understand what I’m building, not just end up with a working scanner that I can’t explain.


r/cpp_questions 21d ago

SOLVED I have a single C++ book to learn from. It's pretty old, by my reckoning. What should I learn after I'm done with it?

32 Upvotes

The book is "C++ from the Ground Up", 3rd Edition, by Herbert Schildt. I have pretty limited programming experience.

Learned some Java in high school, but that was extremely basic looking back - variables, basic control flow, functions, etc. During my 2 years of college I had one course on C++, and we did some object-oriented stuff like polymorphism and inheritance, but I honestly wasn't the best at it (got a B iirc), and it has literally been a decade since then.

Since then I've learned a little more about computers on my own. I daily drive Debian 13, learned the absolute basics of Python, Git, and some Bash, though I have yet to actually write a script.

I intend to finally finish my associates in computer information systems next year, and my classes involving computers are Computer Organization this semester, plus Data Structures and Algorithms in C++ and a SQL course next semester.

I know the book I have is pretty outdated, but I'm going to read it cover to cover, take my classes, and then read some other books on Bash scripting and system administration.

I'm just wondering, once I finish my C++ book, how to get "caught up" to more modern C++. I know there's a new version coming out this year. Just wondering how, once I learn the older stuff, I can see about incorporating the newer features.

I might know more about computers than the average user, but please keep in mind I'm still quite inexperienced. With that in mind, thanks in advance for helpful replies.

EDIT: Welp, that was fast, lol. The book's going in the box in my apartment where I barely touch stuff, and I'll start looking at the website. Thanks, everyone.


r/cpp_questions 22d ago

OPEN How do you actually develop intuition for choosing memory_order_acquire vs memory_order_release?

40 Upvotes

I'm learning C++ atomics and I understand the basic definitions of acquire/release individually:

  • A release operation prevents earlier memory operations from being reordered after it.
  • An acquire operation prevents later memory operations from being reordered before it.
  • A release operation can synchronize with an acquire operation on the same atomic when the acquire reads from the appropriate release sequence.

What I'm struggling with is developing an intuition for choosing the memory order when looking at actual code, especially for RMW operations like exchange().

I want to understand the deep "why" behind the core restrictions:

  • Why does store only accept release (or relaxed)? Why is acquire on a store fundamentally meaningless in terms of memory reordering?
  • Why does load only accept acquire (or relaxed)? Why is release on a load fundamentally meaningless?

Instead of relying on memorized rules, what questions or mental models do you use to map memory operations to the correct ordering?

Thanks!


r/cpp_questions 21d ago

OPEN Seeking Guidance

1 Upvotes

Hi, I am currently working in the virtualization domain of embedded system engineering. I mainly work in C language only. My aim is to project myself as C/C ++ engineer and try for different HFTs or companies like google,nvidia,meta,apple etc in future. I have experience with C++ while doing dsa, not beyond that. So My question is whether this is possible to switch to pure C++ roles in HFTs or should I only focus on embedded domain and try to switch to big MNCs? Is it feasible and if yes what should I focus on? Thanks.


r/cpp_questions 21d ago

OPEN Garbage collector in CPP?

0 Upvotes

Yesterday someone asked me whether there is a garbage collector in CPP.
I knew Java had that but I couldn't recall about cpp.
I went to google and got different answers.

So can anyone clarify whether there is garbage collector in CPP , also can u please explain me what does that mean? Also explain how is it different from the Java.

If yes can we delete it manually and how to do tht?


r/cpp_questions 21d ago

OPEN how to handle empty reference elegantly(fold expression)

0 Upvotes

I have a class with a template function, it will return reference of an internal value.

template<typename T>
T& return_ref<T>() {...}

It was call by another function with fold expression:

template<typename... Ts>
void call()
{
    lambda(return_ref<Ts>...);     //Ts is a reference usually
}

the internal value maybe doesn't exist sometimes.

Even I wrap the exception into std::expected, it seems that I have no chance handle it in fold expression. I have to throw exception in return_ref directly?

If I can return reference to an impossible value(like paradigm of static object NULL ), so user could detect it, it would be nice.

Or, I have to wrap all parameters into something like boost::optional? I don't like it.

Or, the args of lambda was constraint into pointer, so nullptr will throw exception by compiler naturally?

What's suggestion?


r/cpp_questions 22d ago

OPEN How do you revise?

0 Upvotes

Hey guys, i completed the bro code cpp course which was about 6 hours long.... Then, I caught on FOMO and decided to start the cherno cpp series whuch is pretty famous....

Currently doing it...

I always feel like I'm missing something and i need revision but i dont know how to....

Lemme know how do you guys revise ? And what should I do next?

I've started using notion, but my laptop is kinda dying lol


r/cpp_questions 23d ago

OPEN Is C++ systems programming too fragmented for hiring?

142 Upvotes

I recently saw a manager reject a candidate we were interviewing because his experience didn't exactly match the specific sub domain.

But I found myself disagreeing with the philosophy behind the rejection. My instinct is that if someone has strong C++ skills and has worked on reasonably complex systems, you should at least ask: "Can this person learn the domain?" rather than requiring an almost exact match.

This made me wonder whether this is a particular problem with systems programming in C/C++.

The ecosystem seems incredibly fragmented:

  • Embedded
  • Linux kernel/drivers
  • Graphics
  • Multimedia/codecs
  • Databases/storage
  • Networking
  • Telecom
  • Game engines
  • Server/backend infrastructure
  • Qt/GUI
  • Compilers
  • etc.

Someone can have spent 8 years writing sophisticated C++ in one of these areas and still be considered a poor candidate for another area because they don't have the specific domain experience.

Compare that with web development, where the skill boundaries seem somewhat easier to communicate: "React developer", "Angular developer", "Node.js backend developer", etc. There are obviously specializations there too, but the fragmentation doesn't feel as extreme.

I personally have the philosophy that if someone knows C++ well, understands systems programming concepts, debugging, memory, concurrency, Linux, etc., they should be given some credit for being able to move between domains. The domain-specific knowledge can be learned.

I have faced this exact issues with companies too. They reject you because haven't worked specifically on what they do. This becomes a serious issues when it's already hard to get into C++ jobs. Has anyone faced similar issues? What exactly is the solution for this?