r/Cplusplus • • Sep 03 '25

Question There is something wrong with this y=++x+x++

0 Upvotes

If x=0,y=0 And we did this operation y=++x+x++; The course that i am watching and deepseek qwen ai and chat gbt told me that the answer should be x=2 y=2 But visual studio code and another online compiler keep giving me the answer like this x=2 y=3 which make no sense Can anyone explain


r/Cplusplus • • Aug 25 '25

Question is it safe to unistall microsoft visual basic/C++Runtime (x86)

Post image
0 Upvotes

r/Cplusplus • • Apr 01 '24

Answered No matter what I do, The code keeps outputting an endless loop

Post image
0 Upvotes

r/Cplusplus • • Jun 24 '25

Homework newbie question - Why we return 0

4 Upvotes

Why we return 0;

why r we retrning 0 value ?

does it means return false ? 0 = false and 1 = true right?

whyyyyyyyy........

that means if the programme run successful return false?

guys save me


r/Cplusplus • • Apr 15 '25

Tutorial Unlock the Power of C++! 💻✨

Thumbnail gallery
6 Upvotes

r/Cplusplus • • Aug 24 '25

Feedback Umm I don't know what to say.Is there a better way?

Post image
0 Upvotes

I think this should be the better way or tell me an easy one because I am not totally pro at programming in c++


r/Cplusplus • • Jan 27 '26

Tutorial Why I love C++

0 Upvotes

// OC - The Spell

for (long Fn = 0, NI = 1, NJ = 1; Fn >= 0; NJ = (std::cout << Fn << std::endl, Fn = NI, NI = NJ, Fn + NI));


r/Cplusplus • • Sep 04 '24

Question Free compiler for a beginner?

0 Upvotes

I am taking an online C++ class and we need to use a free online compiler to complete the work. I know of a few already such as GCC and Visual Studio.

Which compiler do you think is best for a beginner? Which one is your favorite? BTW it needs to work for windows 10 as that is the OS I use


r/Cplusplus • • Apr 04 '21

Achilles' heel of the status quo?

0 Upvotes

The cover of the Design and Evolution of C++ had a sapling on it. That seems to have been a good choice. C++ has continued to grow since then and is IMO the most important programming language today. There's a lot of complexity to the language already and new features are being proposed. Is the large number of C++ implementations a weakness going forward given the increasing complexity? I tend to think so, but I write this as one who has been working on a global command line. Thanks.


r/Cplusplus • • Jun 25 '18

Multiple Inheritance in C++

0 Upvotes

https://medium.freecodecamp.org/multiple-inheritance-in-c-and-the-diamond-problem-7c12a9ddbbec

I have posted that post and will post a second one for virtual inheritance.

Please share your thoughts. I've been improving myself by trying to teach other people.


r/Cplusplus • • Jan 28 '25

Discussion Let's see what makes it difficult

1 Upvotes

What’s the trickiest part of C++ for you?

268 votes, Jan 31 '25
101 Pointers
41 OOP
34 Recursion
92 STL

r/Cplusplus • • Sep 18 '26

Homework Coding group on Whatsapp

1 Upvotes

Thinking about starting a coding group on Whatsapp where were like minded people can talk about coding and get help with problems or homework (we won't do your homework for you but we'll help you to a solution), let me know if you're interested....


r/Cplusplus • • 1d ago

Feedback Does clangd help claude fix more C++ bugs? I tested it on 255 issues across 40 projects

Thumbnail
gallery
0 Upvotes

LLMs are bad with C/C++ specially while working with large private codebases. There are two broader reasons.

Reason 1: context handing:

consider this actual failure from an HFT:

// risk/checked.hpp
namespace risk {
template <class T> struct Checked {};
template <class T> bool validate(const Checked<T>&);  // generic checks only
}

// gw/order.hpp
namespace gw {
struct Order : risk::Checked<Order> {};
}

// gw/order_validate.hpp
namespace gw {
bool validate(const Order&);  // also checks the venue price band
}

// gw/order_router.cpp
#include "gw/order.hpp"
#include "gw/order_validate.hpp"  // delete this line
namespace gw {
bool route(const Order& order) {
    return validate(order);  // still compiles
}
}

If you deleting include line then validate(order) still compiles. Ordinary lookup no longer finds gw::validate, but ADL looks in the namespace of Order's base class, finds risk::validate<T>, deduces T = Order, and the price band check is gone.

  1. Adding clangd to Claude Code worsens performance

on 255 issues from 40 C and C++ projects, 359 repair attempts with and without the clangd tool. With it: 270 fixed. Without: 275. Across all tasks, cost went up 11%.

  • When the tool was optional, Claude Code used it in 5% of runs (separate test, 30 search tasks).

  • When told to use it, fell back to text search in 70% of runs.

  • On 29 tasks built around same-name functions (find the callers of one specific function, ignore the others with the same name), plain Claude Code found 96.6% of callers. Requiring clangd added 0.6 points.

Interestingly, for 126 of the 255 issues, the model could name every location that needed changing from the issue text alone, without seeing the repo from memory only. A lot of public issues don't test code navigation much.

Paper: https://byteask.ai/research/lsp-claude-code-cpp

2. Ranking code based on AST+build system

I implemented an index which reads the project through its build (compile_commands.json, flags, macros, what each call resolves to), AST, semantic embedding with decoders derived from C/C++ and ranks where a change probably belongs with respect to git history and comments from PR. On 30 real issues from open-source C and C++ projects, held out from development, it ranked a file that needed changing first 57% of the time. sgrep: 30%. Probe: 20%.

It indexed the Linux kernel build in 9.3 minutes and LLVM in 13.7 on one 48-CPU machine. Comparable products like Graphify hadn't finished LLVM after 3 hours. After a .cpp edit it re-indexes in 5.8 seconds, and 9 of 10 answers after an edit matched the new code, vs 0 of 10 from a stale index.

Papers: https://byteask.ai/research/context-engines-cpp and https://byteask.ai/research/context-large-codebases-cpp

Reason 2: Lack of right tools.

Claude Code and Codex can run gdb or perf as one-off shell commands, but out of the box they can't drive an interactive gdb session or work with perf data directly. I open-sourced a fork of Codex with them built in as native tools: https://github.com/ByteAsk/cli. PRs adding more tools are welcome. Interestingly with working at harness level, you can add different and multiple models, context engineering for working around larger contexts with better control.

3. Same model, same fixes, fewer tokens

I compared with above index + new harness with OpenAI's Codex CLI running the same model. This setup used 63 to 80% fewer tokens and cost 59 to 70% less. The gap was biggest on little-known projects the model is unlikely to have memorized.

Paper: https://byteask.ai/research/byteask-system-cpp

If you've tried AI tools on C/C++/CUDA codebase, where did they fall over? my guesses for the hard cases are macro-generated code, CRTP and heavy ADL, unity builds, C++20 modules, and projects without a usable compile_commands.json.


r/Cplusplus • • Jun 20 '26

Feedback [C++ noob] so here the other day i was introduced to <cmath>.

0 Upvotes

i got introduced to <cmath> (still onto this )the day before yesterday then got depressed due to some shit life throws at you and randomly went "Welp, I can make a quadratic equations solver with this"

how can i improve this?

(slightly lengthy rant ahead )

also, great thanks to u/mredding , although i didn't understand like 90% what they told me, the remaining 10% did help me understand code a bit more and i wanna say, i don't think i can understand what u call simple at all, but that's due to being new to c++.

other than that, i did try to make my code a bit more to the point and not variable spam ( just remembered to replace "return 0" with "return Exit_Success" ) and now understand how to use if/else. and the reason the "#include <iostream>" are below cuz it's my practice folder i like to keep them near the what i'm doing in case i need to add smt.


r/Cplusplus • • Aug 30 '25

Question help what is this

Post image
14 Upvotes

huh?


r/Cplusplus • • Jun 17 '26

Discussion I don't know where to post this. I present: A sprite undergoing speen, made with a C++ Program. This gif is real time.

2 Upvotes

r/Cplusplus • • Dec 28 '21

Code review

0 Upvotes

I've made a number of changes since I posted the request for code review, and since some people have time off now, I'm posting it again.


r/Cplusplus • • Dec 24 '25

Homework My first c++ code.

21 Upvotes

#include <iostream>

using namespace std;

string name = " jerry ";

int age = 62;

float pi = 73.3824383;

int main() {

cout << "name: " << pi << name << age << endl;

}


r/Cplusplus • • Sep 29 '26

Question can i convert the integer into string in manual way

Thumbnail reddit.com
0 Upvotes

r/Cplusplus • • Jul 26 '24

Discussion What non-standard goodness are you using?

0 Upvotes

One non-standard thing that a lot of people use is #pragma once.

As you may know if you have been around Usenix or Reddit for a while, I've been developing a C++ code generator for 25 years now. The generated code can be used on a number of platforms, but I develop the software primarily on Linux. So, I'm particularly interested in the intersection of non-standard goodness and Linux.

Some will probably mention Boost. So I'm going to also mention that I have serialization support for the base_collection type from the PolyCollection library.

Thanks in advance.


r/Cplusplus • • Apr 09 '22

getting started

0 Upvotes

Anybody got advise on getting started coding. I've been looking at some freelance but I have no idea how to get started.


r/Cplusplus • • May 11 '26

Question Why is the command not running even after installing mingw

Post image
0 Upvotes

r/Cplusplus • • Sep 19 '23

Homework Integral or unscooed enum type?

Thumbnail
gallery
0 Upvotes

Hey all! I stumbled into this sub quite desperately and frustrated but it looks very interesting 😎 I feel like I have the understanding of a toddler in terms of programming and I've been working in this one for a little bit now in my intro class and I think that I have it close to done I'm just getting these errors thrown from one of my equations. Any and all help is appreciated greatly❤️


r/Cplusplus • • Oct 08 '26

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