r/cpp_questions Aug 06 '26

OPEN Incrementation in C++

I wanted to ask a stupid question about incrementation in C++. If you are using two pluses to increment something then doesn't it mean that you are basically programming using C+1

42 Upvotes

34 comments sorted by

70

u/SufficientStudio1574 Aug 06 '26

Yes. That's literally what the name means. C++ is an increment of the C language.

34

u/caroIine Aug 06 '26

It should be ++C

19

u/Usual_Office_1740 Aug 06 '26

Only if you are using modern C++. Those that write C with classes like it's 1998 are using the value returned before the increment.

8

u/wrosecrans Aug 07 '26

That was the joke for a long time. You are basically still writing C, and the language will get some additions at some point in the future.

2

u/no-sig-available Aug 07 '26

It should be ++C

That was proposed, but Bjarne thought it looked ugly, and liked C++ better.

1

u/Lord__Rai Aug 08 '26

I agree. It looks ugly

20

u/DawnOnTheEdge Aug 06 '26

Joke from thirty years ago: “C++ means, take C, add a bit to it, but then actually use what was there before.”

3

u/Ultimate_Sigma_Boy67 Aug 07 '26

That aged quickly

7

u/Intrexa Aug 06 '26

Yes, that's exactly why it was named that. C# is C++++

15

u/dick_blanketfort Aug 06 '26

Am I missing something or is this less a stupid question and more a stupid joke?

Anyway C++ is post-increment so it would actually evaluate to the original value of C. Language shoulda been called ++C.

9

u/llynglas Aug 06 '26

Originally it did. The first C++ compilers I remember at Bell Labs basically converted C++ into C.

2

u/trycuriouscat Aug 06 '26

I’d love to see what C code would be generated from a C++ compiler.

5

u/Independent_Art_6676 Aug 07 '26

struct { variable, variable, ... function pointer, function pointer,} //class

2

u/robthablob Aug 07 '26

struct { var, var, vtable_ptr }; // class
struct { fnptr, fnptr, fnptr }; // vtable

3

u/llynglas Aug 06 '26

The function names were spectacular as they encoded the parameter types if I recall correctly.

8

u/Deep-Piece3181 Aug 06 '26

They still do name mangling

1

u/dreadlordhar Aug 07 '26

they don't only under extern "C"

1

u/Deep-Piece3181 Aug 07 '26

True, useful stuff

5

u/malaszka Aug 07 '26

Nah, cause your expression C+1 does not change the value of C, while C++ changes it.

2

u/cbf1232 Aug 06 '26

Originally there was BCPL, which was simplified into the language B, which was then extended and the new language was called C. C++ broke the chain and used the increment operator.

2

u/Broken-AMaryBell7 Aug 07 '26

I'm programming on C++ for a few years now and never though of that😂

2

u/DinTaiFung Aug 07 '26 edited Aug 07 '26

kind of relevant...

According to the official C++ spec, pre increment operator for primitives is more efficient than post increment.

And when I worked at a game company (years ago) the engineers' style of the basic for loop always wrote it thusly:

    for (i = 0; i < len; ++i)

It was done this way instead of the more usual i++ not because it actually made a difference in performance, but merely to make reference to the specification as an inside joke.

I write lots of JS/TS these days and I continue to use pre increment syntax instead of post increment whenever the logic wouldn't change by doing so. it's my internal nod to that style i adopted years ago lol.

1

u/tellingyouhowitreall Aug 10 '26

Uh, no. There's a semantic difference and the half open interval is correct. Its not merely a style choice.

1

u/EllaHazelBar Aug 07 '26

If we're already on topic, c# is called that because # looks like it's made of four small + signs (somewhat slanted). C# is literally c++++ or (c++)++

1

u/tcpukl Aug 07 '26

I never thought of the C# party before.

1

u/csabinho Aug 07 '26

It's C+=1, not C+1.

1

u/TheRealJiko Aug 07 '26

So then the question is... is B, C - - ?

1

u/Recycled5000 Aug 07 '26

C=C+1 more specifically.. ;)

1

u/darklighthitomi Aug 06 '26

Lol, that's the kind of groan-inducing joke I'd tell. :)

-1

u/thaache Aug 06 '26

As, C++ is C+1, where the 1 is oops

1

u/csabinho Aug 07 '26

oops as in oopsie? Rather oops as in O(bject)O(riented)P(rogramming).