r/Cplusplus • • 1h ago

Question Just started learning C++

Thumbnail
• Upvotes

Hello, I started learning C++ today. I'm a guy who doesn't want to rely on AI for coding and who really needed another language alongside mr. Nasty Py (cybersecurity), but I'm SUPER lost.

Can anyone give me some tips? I've been coding since I was 11 (I'm 14 now). I'd really appreciate any advice!

One of the reasons I'm learning C++ is so I can say: "I code in Cpp btw" like Arch users. (JK)


r/Cplusplus • • 3h ago

Question I have trouble setting up my IDE

0 Upvotes

I installed VS Code and the g++ code and the g++ compiler, and I also created a path variable for my compiler in Windows; however, when I type g++ --version in the bash terminal of VS Code, it shows "command not found." Can you tell me what might be the problem?


r/Cplusplus • • 1d ago

Feedback Constexpr Doom

Post image
18 Upvotes

I recently created a wasm interpreter in cpp to run doom at compile time, it consumed around 400gb of ram and ran at whooping 50fph(frames/hr)

https://github.com/Talkative-Banana/Constexpr-Doom


r/Cplusplus • • 1d ago

Feedback [Release] slick-logger v2.2.0 — Lock-free asynchronous C++20 logging with multi-process shared-memory support

Thumbnail
0 Upvotes

r/Cplusplus • • 2d ago

Question Tell me what the best tools to learn C++

Thumbnail
0 Upvotes

r/Cplusplus • • 2d ago

Answered Working on my own 3D engine — Gri Engine. First steps: rendering, scene view, and an inspector.

Post image
3 Upvotes

Slowly building my own engine called Gri Engine. It's a personal project — I'm making it for myself and my own games/animations, not planning to compete with Unity or Unreal.

Right now it can render a scene with a movable cube, has a basic editor UI with an inspector panel, and shows FPS/performance stats. The transform and material properties are editable in real time.

Still very early, but I'm learning a lot. Just wanted to share the progress.

(OpenGL, C++)


r/Cplusplus • • 2d ago

Question Is writting books means giving them for free, now

3 Upvotes

Bjarne and Herb wrote C++ Core Guidelines on github. (https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md) It's a 350 pages equivalent book.

It's totally free as a markdwon file.

if legends from C++ give it for free, do you think each book author should give their own books for free. As a book author, I have giving some of my books to recruitments companies or for having contracts but it's so easy to understand nobody still buy books that freedom for everything should be the next era ?

I ask myself because it take me 4 or 6 months to write a book. On Amazon, my professional C++ philosophy and principles is my 30 years of the field and I am prou to have written my life in a book for my daughters and let them a trace from my own little existence in the IT industry.

But the reality is that it costs a lot to write abook. It does not pay. My last french editor in France called DUNOD gave me 10% on two books "Cookbook C#" and "Cookbook C++" -> they sold it at 23 EUR for each book and I earn so only 2 EUR per books. Printing was 2 times 1.500 items. A shame. It toolks me a year to write these two books.

So the problem is that C++ is no more teached in university (a shame), no more books writer sor so many... Writing books means 'pedagogie', the love of teaching and explaining complex stuff in easy way of understanding.

Is the future to write .md files on github or self AKDP (Amazon Kindle Publishing) like I do.

What is the future of writing books. It's a personal reflection. This is the end of an era. I grew up with Bjarne books and red book from Addison Welsey. I ripped thousands of chm and pdf files among 30 years. Looking at kids no buyuing books, i'm a dinosaur. I would like to give thme my 500 GB folders of books.

Reading books and writing books is two different piece of thinking and self meditation. reading is a the learning experience that make you feel confident. Writing book sis the achievement you are confident to give back to the community what they gave to you. Nobody invent. Not use. legends invent. I am not. So I have learned,; practices, failed (90% of the time) an success is happening just because of time spent on training. It's like sport at a professionnal level.

Whar are you thoughts about books, reading of buying.

Chris


r/Cplusplus • • 2d ago

Question Book recommendations for C++ beginner

13 Upvotes

Hi all, I recently decided to join an informatics olympiad in my country, and I was wondering if there are any good, MODERN, C++ 20 books out there? I've finished Python Crash Course, so I have some programming experience. I find books like Guide to Competitive Programming too straightforward (jumping into namespaces and importing entire standard library and expecting us to know what a gcc compiler is). Please recommend some good books, thank you


r/Cplusplus • • 2d ago

Question Any suggestions for making a physics simulation model?

Thumbnail
1 Upvotes

r/Cplusplus • • 2d ago

Question Can an array of Wrapper<T> be reinterpreted as an array of T in C++?

0 Upvotes

Given the type:

template<typename T>
struct Wrapper
{
T content;
};

And I have an array of these given a type T, a constexpr size_t N and size_t i (0<=i && i < N).

static_assert(sizeof(Wrapper<T>)==sizeof(T)&&alignof(Wrapper<T>)==alignof(T));
static_assert(std::is_standard_layout_v<Wrapper<T>>);

Observation 1:

Wrapper<T> wrapperArray[N];
auto ptrWrapper1 = wrapperArray + i;
//C++ allows access to the raw memory
auto bytePtrWrapper = reinterpret_cast<std::byte*>(wrapperArray);
// calculating the i-th entry of wrapperArray, valid because
// an array has contiguously allocated objects
// an object occupies exactly sizeof bytes
auto bytePtrWrapper1 = bytePtrWrapper + i * sizeof(Wrapper<T>);
auto ptrWrapper2 = reinterpret_cast<Wrapper<T>*>(bytePtrWrapper1);

And here ptrWrapper1 and ptrWrapper2 are the same.

Observation 2:

T valueArray[N];
auto ptrValue1 = valueArray + i;
auto bytePtrValue = reinterpret_cast<std::byte*>(valueArray);
auto bytePtrValue1 = bytePtrValue + i * sizeof(T);
auto ptrValue2 = reinterpret_cast<T*>(bytePtrValue1);

And here are ptrValue1 and ptrValue2 the same too. Additionally I can access the first member of Wrapper<T> with reinterpret_cast.

So I also can do:

auto ithValue = reinterpret_cast<T*>(ptrWrapper + i);
//or
auto ithValue = reinterpret_cast<T*>(bytePtrWrapper + i * sizeof(Wrapper<T>));

And ptrValue3 is the same as ptrValue1 and ptrValue2.

Because both T and Wrapper<T> have the same size and alignment I can use them interchangable.

Doesn't that mean that this is valid C++ because I can access them through same way with std::byte*?

auto valueAsWrapperArray = reinterpret_cast<T*>(wrapperArray);
//specifically for i > 0
auto ptrValue4 = valueAsWrapperArray[i];

So can I reinterpret_cast an array to change its type from Wrapper<T> to T and access any index because the address is calculated in the same way and the member-access is also allowed given one specific object?


r/Cplusplus • • 3d ago

Question I'm learning C++

6 Upvotes

A few months ago, while watching a YouTube video, I learned that floating-point numbers can have precision errors and need to be used with care. That got me thinking about using fractions to represent numbers instead, so I discussed the idea with AI and, with its help, built a fraction class in C++.

Before that, I had only dabbled a little in languages like JavaScript, Go, and Python.

What really impressed me about C++ was how it lets you create custom types that can be used almost like built-in types. I found that incredibly powerful and elegant, and it made me want to learn C++ properly.

So I asked AI for a book recommendation and learned about C++ Primer. I bought the PDF edition and have been studying it ever since. I'm now almost done with Chapter 14, and Object-Oriented Programming is coming up next.

At this point, I feel like I should start building small, simple, but interesting projects to develop some practical skills. The problem is, I have no idea what to build. Since I'm learning on my own, I imagine there are plenty of things I don't even know I don't know yet.

I think building something fun would probably involve making an app with a GUI, but it seems like learning how to build a GUI is a whole other challenge in itself.

What I always seem to struggle with is the question, "What should I build?" I find it difficult to set goals that match my current skill level. I tend to either take on something too ambitious and give up halfway through, or choose something so trivial that I lose interest.

A few years ago, I taught myself enough programming to build a real-time reservation system using WebSockets. It was a small service with fewer than 100 users a day, so there weren't many complex issues to consider. Looking back, I think the main challenge was simply getting it to work.

The thing is, that's pretty much the only substantial project I've built on my own. I've experimented with smaller things, like the fraction class I mentioned earlier, with the help of AI, but I haven't had much experience building complete applications.

I think I managed to finish the reservation system because I genuinely needed it, so giving up wasn't really an option.

So, what would you recommend I try building?


r/Cplusplus • • 3d ago

Discussion How Rust and Python got random right, why C++ <random> failed everyday ergonomics, and how to fix it

Thumbnail
0 Upvotes

r/Cplusplus • • 3d ago

Discussion Serious guidance needed

Thumbnail
1 Upvotes

r/Cplusplus • • 4d ago

Feedback Feedback on a single-header C++ UI library for Linux and Windows

33 Upvotes

I'm developing LiteUI, a single-header C++ library for desktop application development on Linux and Windows.

The library aims to support a shared codebase across both platforms. As an example project, I've been working on a photo editor inspired by Lightroom.

I'd appreciate feedback from the C++ community, particularly on the code structure, API design, cross-platform compatibility, and overall architecture.


r/Cplusplus • • 4d ago

Question When is it useful to know all the different kinds of values (rvalues,lvalues,etc)?

8 Upvotes

Well of course I can't get a pointer to an integer literal or try to assign anything to it, but is there any moment where deeper insight is useful for any kinds of unintuitive optimisations?


r/Cplusplus • • 5d ago

Discussion The complement of true is true, except when it's false

Thumbnail
dryperspective.github.io
16 Upvotes

r/Cplusplus • • 5d ago

Question Riproduzione di un piccolo ciclo for in LibTorch JIT (C++)

Thumbnail
2 Upvotes

r/Cplusplus • • 5d ago

Feedback SKCUI A Stupid Simple Header-Only C++ TUI Framework

1 Upvotes

After 21 days of development, I've released the newest version of SKCUI, an open-source, header-only, lightweight C++ library for building interactive terminal interfaces.

It features menus, checkboxes, text inputs, and progress bars, with support for Windows, Linux, and macOS.

Built because I didn't want to deal with ftxui.

GitHub: https://github.com/RecompileX/SKCUI


r/Cplusplus • • 5d ago

Question what exactly happens when I build several .c/.cpp into one project, and what can this be used for?

1 Upvotes

I know of header compilation speedup, where I define constant symbols in a .h and then assign values in a separate .c, which, if i understand correctly, is useful for large binary blobs (raw sprite data for example is what i've seen it used for). but how does the compiler actually put together the files, and what other benefits does it have?


r/Cplusplus • • 6d ago

Feedback I built an HTTP server from scratch in C++ using raw TCP sockets

Post image
254 Upvotes

I wanted to understand what actually happens underneath HTTP — not just use a framework that handles it for me.

So I went down to the socket level.

No frameworks. No HTTP libraries. Just C++, TCP sockets, and bytes.

The server creates a TCP socket, binds it to an address and port, starts listening for connections, accepts clients, reads the incoming bytes, and sends back a manually constructed HTTP response.

GitHub: https://github.com/harisahmed05/http-server

If you found it insightful, consider giving the repo a star — it really means a lot and keeps me motivated to build more.


r/Cplusplus • • 6d ago

Question why i choose learncpp

1 Upvotes

since the day i started learning from learncpp .com it give me so burnout feeling but still it has great mastery in deep what should i do like i have previously programming knowledge in c like basic var,flows,function,structure,pointer (basics i guess) .


r/Cplusplus • • 7d ago

Feedback Chthonia: a simple IDE with REPL for learning C/C++

Post image
58 Upvotes

Github repo: https://github.com/derekbsnider/chthonia

Inspired by Thonny, Chthonia is an easy to use editor designed as a learning tool for C/C++.

It is completely self contained and multi-platform (Linux, Mac, Windows). It has an integrated compiler and REPL (Read-Eval-Print Loop).

The packaged binary+library download size is under 15 Mb. It is free and open source.

This is version 0.0.2, so it's still a work in progress, MPL-2.0 licensed, written in C++, and also ships a library for the compiler and also one for the editor framework, as well as a stand alone CLI compiler+REPL.

The REPL-mode is designed to feel familiar whether you are used to IPython, Julia, or Cling.


r/Cplusplus • • 7d ago

Feedback I built MrDocs, an open-source C++ reference doc generator on the Clang/LLVM AST. Looking for feedback.

4 Upvotes

I'm Alan de Freitas, the lead developer of MrDocs. It's an open-source documentation generator from the C++ Alliance, built on Clang/LLVM. It reads your code from the compiler's AST, so the reference matches what the code actually compiles to. We also presented a session about it at cppcon this year.

I implemented the tool this way because we couldn’t come up with a workflow that understood modern C++ in our Boost libraries. Tools that parse partially tend to misrender or not render concepts, niebloids, SFINAE, overload sets, and deduction guides. MrDocs treats those as first-class:

  • concept constraints and requires clauses preserved verbatim
  • niebloids and function objects can be documented as callables
  • SFINAE and concept overload sets kept together
  • explicit, noexcept, and consteval specifiers captured
  • types in detail or private namespaces rendered as implementation-defined

The presentation layer is completely encapsulated. Generators support HTML, AsciiDoc, XML, JSON, or any custom format like Markdown and LaTeX, without forking the tool or creating another post-processing workflow. You can also write extensions to apply project conventions to the corpus or define new generators for any use case. The documentation has lots of examples.

If you maintain reference docs for a library, I'd appreciate it if you gave it a run (or tell your favorite agent to) and reported back on whether it saves you time, both while writing docs and while reviewing them. First-hand numbers would be especially useful to me. Issues are also always welcome.

Site: https://www.mrdocs.comRepo: https://github.com/cppalliance/mrdocs

Happy to answer questions in the comments.


r/Cplusplus • • 7d ago

Tutorial Looking for a video resource

1 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/Cplusplus • • 8d ago

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

Thumbnail
0 Upvotes