r/cpp_questions • • 11m ago

OPEN Как устанавливать сторонние библиотеки на С++?

0 Upvotes

Hi everyone! I’m learning C++ and have a question: how do you install third-party libraries? For instance, in Python, you just type `pip install` in the terminal—what’s the equivalent for C++?


r/cpp_questions • • 5h ago

OPEN Where to start learning C++?

11 Upvotes

Hi everyone! I want to start learning C++, but I’m not sure where to begin. As my first goal, I plan to build a simple 3D viewport to understand how everything works in practice. Could you please advise on where a beginner should start?


r/cpp_questions • • 10h ago

OPEN How to learn c++ effectively and be profficient in it?

7 Upvotes

Maybe you've heard this question before, but I want to know. I've been studying c++ for a month now, and I feel like I know some of the basics, but I know that I need a different approach. I feel like I just memorize it instead of getting it. I want to learn it truly,the right way. I write a lot of code cause I know thats the best but I fall short on the thinking like a programmer part. I want to lean c++ independently,then switch to ue5 and work on a game. I would love it if you would share your methods and links to some good c++ literature. I know I'm not dumb and I know it's not easy. I am not looking for a quick solution, just the right one.


r/cpp_questions • • 17h ago

DISCUSSION Why C++?

0 Upvotes

C++ is a general-purpose, performance-focused programming language used across many different fields, and I'm really enjoying learning it. However, I keep seeing a lot of experienced developers criticize it heavily. Linus Torvalds famously trashed the language, even calling it a "horrible language":

"C++ is a horrible language. It's made more horrible by the fact that a lot of substandard programmers use it, to the point where it's much, much easier to generate total and utter crap with it. Quite frankly, even if the choice of C were to do nothing but keep the C++ programmers out, that in itself would be a huge reason to use C."

He basically called C++ developers idiots. Even though he made this comment years ago in 2007, to be exact, it's starting to make me doubt my choice. And it's not just Linus; other tech pioneers and plenty of people on Reddit talk negatively about C++ as well. Different people have different critiques about the language claims such as, it's memory unsafe, violates clean language design principles, and more.

So, are these critiques mostly aimed at older versions of C++, and did modern C++ (C++11 and beyond) actually fix these issues? What are your thoughts?


r/cpp_questions • • 17h ago

OPEN What is the best way to learn C++ for control theory implementation? Should I learn python or C++?

2 Upvotes

My background:

I'm a 5th year mechatronics engineering student that is good with matlab/simulink and is looking to expand my skills for my future career in automation/control/robotics.

I already know the basics of C++ from the course I took in college. Also, I am pretty good at 86 assembly programming. I heared that python is only used for simulations but that is what I use matlab/simulink for.


r/cpp_questions • • 22h ago

OPEN Is there any free interactive learning like rustlings/ziglings for cpp?

13 Upvotes

I find rustlings/ziglings to be really strong at helping me learn concepts and have it stick.


r/cpp_questions • • 23h ago

SOLVED Performance of std::vector

26 Upvotes

In the university we had to implement quicksort, the unsigned ints are stored in std::vector. I have accidentally discovered, that all algorithms, despite how students implemented them, are much faster when instead of directly accessing data from the vector like that:

arr[n]

we write:

unsigned int *a = arr.data()

and access that data by writing:

a[n]

But I can't understand why is that, in both cases it translates to one and the same: *(a + n)

The code is compiled on Clion IDE if that changes anything, no custom settings for compilation are used.

I can't directly share the algorithms for copyright reasons as they are not mine.


r/cpp_questions • • 1d ago

OPEN Looking for a beginner-friendly C++ book

2 Upvotes

I recently decided to dive into programming, and I picked C++ as my first language. I realize it's a tough and complex language, but I'm drawn to it because I find it really fascinating.

That said, I'm wary of getting overwhelmed by the advanced topics right from the start and ending up in a tutorial loop where I'm just stuck learning without actually creating anything.

With that in mind, I'm on the lookout for book recommendations that strike a balance, something that won’t bury me in every intricate detail, but will still help me learn enough to work on some cool and practical projects.


r/cpp_questions • • 2d ago

OPEN Bluetooth pairing

0 Upvotes

Guys am trying to have a Bluetooth manager(connect multiple device on one Bluetooth) work using cpp the thing is am not that good at cpp any recommendations. I tried using ai for advice but holy sh*t it's making it worse


r/cpp_questions • • 2d ago

SOLVED Confused between using learncpp or a book ? if book reccommed me the best ones

3 Upvotes

I have studied basic python in my high school , i have some foding knowledge and i know c till pointers , should i ue learncpp for learning cpp or any book , if bookplease give me the best ones


r/cpp_questions • • 2d ago

OPEN Which book is the best for learning systems programming and low level in Modern C++ (17/20)

32 Upvotes

I have done some systems programming in C and C-style C++ with some operator overloading. But I want to learn Modern C++ (17/20) too and keep on doing systems programming along with low-level dev, which books do you recommend for me to follow?


r/cpp_questions • • 2d ago

OPEN Is C++ used outside of Unreal engine?

0 Upvotes

I feel like this is a really dumb question but I have been wondering if C++ is only used in game engines. I know godot also supports C++, but I saw some random comments mention that other companies like robotics or just other tech companies in general use C++ and now I'm really curious.

I'm currently in my first year of uni for game dev and we're learning blueprints atm, but I've been thinking of learning C++ in my spare time. After hearing about ue6 and verse, I got kinda nervous about the future of both blueprints and C++. I imagine a lot of companies will continue to use ue5, but if other industries use C++ it gives me a lot more opportunities, especially if I spend my next 3 years of uni being really productive with code and whatnot.

Thank youuu

Edit: Ok thank you everyone, I had no clue it's basically used for everything. All of your responses definitely make me feel a lot better regarding the opportunities I'll have when I graduate, as that was the main concern..

I'll get a head start on learning C++, very excited!!


r/cpp_questions • • 2d ago

OPEN Is this possible?

9 Upvotes

I’m working on a game engine as a way to learn C++ and CMake. I’m attempting to create an editor for my engine, and I want to use ImGui. I’ve been going back and forth about whether I want ImGui on the engine or editor, but I think I want it on the engine because the engine owns the main loop, so it can just do the imgui frame lifecycle stuff. Also, if I ever decide to learn Vulkan and switch to it (unlikely), I don’t think I’d need to update the editor.

The problem with putting it on the engine is that the game will now have ImGui and this code running each frame, not actually doing anything. I’m sure this has little to no impact on performance, but I feel like it’s unnecessary?

Anyways, I’m wondering if it’s possible to make it so that if I run the editor, then the ImGui code runs otherwise, it’s stripped out. I know there is conditional compilation I just don’t know if that is something that can be done in this scenario?


r/cpp_questions • • 3d ago

OPEN Rendering text through ImGui?

2 Upvotes

I'm hoping to get a basic repl running with ImGui, OpenGL, and GLFW. I'm comfortable with GLfW and OpenGL rendering but not the ImGui portion.

My question is, can I use the OpenGL context and the GLFW window and then get basic text editing functionality with just ImGui? No opengl buffers, no custom shaders. I think the opengl context needs a default vertex and fragment shader to function but I'm looking to keep that very minimal and handle basic repl input and text rendering between imgui::begin() and imgui::end(). A basic per keypress render loop where each GLFW key event updates a string and then ImGui renders a new frame for the window. I haven't worked with ImGui before. Do you think this is possible?


r/cpp_questions • • 3d ago

OPEN Is C++ worth it?

48 Upvotes

I've been wondering whether learning C++ would be worth it. I'm really interested in hardware design. I've even built my own CPU in Logisim, and now I'm looking to get into parallel programming and GPU computing.

I also enjoy programming highly efficient simulations and machine learning projects purely out of curiosity. Would C++ be a good investment for these interests, or would I be better off focusing on other languages?


r/cpp_questions • • 4d ago

OPEN how do header files work?

17 Upvotes

been trying to learn c++ recently, but ive been caught on header files. I have been told that they declare functions/variables, and including them basically makes the compiler copy/paste it above the code. however, i still dont quite understand it. How does the compiler know what to run in a function declared in a header file if there's no definition? My intuition tells me i need a .h file and a .cpp file along with the main file in order for it to work but i still dont understand how that would let the code run.

would i declare a function in the header file and then write the inside of the function in the cpp file?

like with the following code

//in blah.h

int sum(int a);

*********************

//in script.cpp

#include blah.h

int sum(int a)

{

return a+1;

}

******************

//in main.cpp

#include blah.h

#include <iostream>

int main()

{

std::cout << sum(1);

return 0;

}

*****************

would that compile?????????

and even so, how does the compiler read that?????

does it like know the declaration then search for the definition????


r/cpp_questions • • 4d ago

OPEN Going to Study OOPS in C++ From Tommorow, any advice???

5 Upvotes

Just Completed basics of C++ Programming language like :- \*Syntex

\*Logical Operators

\*Conditional Statements

\*Loops

\*Some of data Structures like :- 1.Arrays , 2.Vectors , 3.Stack , 4.Queue

Now going to Study OOPS from tomorrow, Seeking for advices Based on Practical Industry Experience.

It will be a lot of help


r/cpp_questions • • 4d ago

OPEN Learning to write video games from scratch

8 Upvotes

Hello everyone! This year I took a course on game development programming. I learnt alot of cpp basics, and eventually went on to write:

  • a couple classes from the Standard Templated Library
  • some trees and sorting algorithms
  • matrix and vector types for a raylib game (math as well)
  • a small raylib game with tanks
  • some enemy ai stuff such as pathfinding algorithims, a state machine & a behavior tree

eventually the course went into more Unreal Engine territory and I feel that as a C++ dev, it leaves alot to be desired. There's heeps I need to learn, and I want to also break it down to the basics before I go and write some more complex and large programs, but my end goal is write games basically from scratch, with the use of maybe some libraries at the very best. I do not enjoy or like the smell of game engines, since I do not know what is really happening underneath. I am trying to create a curriculum for myself for this coming year, of things to study on my own. Some ideas for what I want to do this year are: (in no particular order)

  • eventually create a 3D rendering engine (and understand the maths that makes it all work)
  • eventually write a minecraft clone (for learning purposes)
  • make some sort of RPG based heavily on this new game coming out on steam UNDERKEEP
  • and eventually.. become a C++ wise guy and make sellable games from scratch

does anyone have any suggestions, books, tutorials/guides, things to try and write, or communities to join, any suggestions at all? Thankyou!


r/cpp_questions • • 4d ago

OPEN cpp class vs namespace

3 Upvotes

in my personal opinion, at least half of the purpose of using nested namespace is to manage visibility, the rust's mod allows it but cpp's namespace does not, only class allows it( the public and private)

is using classes with static functions inside everywhere instead of using namespace an already existing way to use the "namespace" in a way that i can more conveniently manage visibility?


r/cpp_questions • • 5d ago

OPEN C++ and Data structure

3 Upvotes

Which topics of C++ required for Data Structure??


r/cpp_questions • • 5d ago

OPEN Reccommend Book

0 Upvotes

finding a book that teaches from basic intermediate to advanced c++ and also have projects in it.


r/cpp_questions • • 5d ago

OPEN Book on cpp

0 Upvotes

So i was looking on amazon for a book about cpp and i found this https://a.co/d/06VJe0OR and was planning to buy it. The people that have read and used it is it good for learning the language?


r/cpp_questions • • 5d ago

SOLVED How do you implement/create tests correctly ?

4 Upvotes

Hi !

I have been working on a personal project for 9 month which allowed me to learn a lot but I’m going through a somewhat more challenging phase as I explore unit testing due to CMake configuration and project architecture.

I choose Google Test but my questions are not very specific to this framework. Like I said, I already have a lot of code and I want to use tests cause it seems very useful to create a solid program.

Moreover, my project is a library + an executable so this complicates things in the linkage for example.

How do you manage tests ?

What do you test (because the test exec doesn't have access to private method or private include of a library) ?

About CMake and Google Test, are there any things I should watch out for ? How properly use folders to organize that ?

Do you have any recommendations on where I should look to learn more on the good habit with that ?

I can give you more information if you need, thanks for your time !


r/cpp_questions • • 5d ago

OPEN Integration testing using gtest

2 Upvotes

I am confused about what is the meaning of integration testing. I have done unit testing using gtest where we will mock whatever external dependencies are there for the targeted unit (function) to test all range of values that covers all lines, functions and branches.

If we say integration test is meant to use real code instead of mocking. Then I am getting this doubt that lets say we have 3 components (separate processes) running and dependent on one another in a embedded system.

A -> B -> C

So if you are calling an api provided by A it will internally talk to B and then through C and return the result over IPC.

Now to do integration testing using gtest, do I need to compile this into a single binary by eliminating the IPC and include each code as a library. This way I have a single proces that runs gtest with all the components logic but excludes the real IPC communication.

Or instead should I keep the individual processes to be running separately and link my gtest binary to the component A so that the communication flow through the components in the target environment.

In both ways how we would actually be checking the interactions? And which one are you guys using?

Context:
Language used: C++
Domain: Automotive IT (TCU software)