Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7747403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:31:13+00:00 2026-06-01T10:31:13+00:00

Possible Duplicate: Is there a performance difference between i++ and ++i in C++? In

  • 0

Possible Duplicate:
Is there a performance difference between i++ and ++i in C++?

In C++, I see people frequently use ++p in a for loop or elsewhere, where you want to increment a value, but not use the return value. I’ve heard this is more efficient because p++ returns the value before incrementing, and thus requires a temporary space.

But, it feels that even a very ignorant compiler will pull out that return value as dead code (as long as the increment code is inlined, and so the compiler can see that the return value wasn’t necessary).

I’m trying to come up with a good example where, using some sort of iterator, iter++ will actually create the copy (even though the return value of iter++ is not used.

After all, we don’t really frequently consider register allocation either when we write code with iterators.

I learned to use p++ simply because that’s what the book I learned from did. Is preferring ++p when no return value is used an archaic practice, or simply part of elegant coding? And why is the language not called ++C then?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T10:31:15+00:00Added an answer on June 1, 2026 at 10:31 am

    p++ is slower only when ++p doesn’t do the job – i.e. when you actually use the return value. Otherwise, the compiler will optimize the code to the same thing.

    People prefer using ++i instead of i++ because it describes better what you intend to do: increment i, more than increment i and return the old value. Of course, you tend to stick to old habits. If you’re used to writing i++, that’s ok, unless the coding standards of the company you work for mandate you use ++i.

    Chapter 3 of D&E: “I picked C++ because it was short, had nice
    interpretations, and wasn’t of the form "adjective C."’ In C, ++ can,
    depending on context, be read as "next," "successor," or "increment,"
    though it is always pronounced "plus plus." The name C++ and its
    runner up ++C are fertile sources for jokes and puns — almost all of
    which were known and appreciated before the name was chosen. The name
    C++ was suggested by Rick Mascitti. It was first used in December of
    1983 when it was edited into the final copies of [Stroustrup,1984] and
    [Stroustrup,1984c].

    Chapter 1 of TC++PL: “The name C++ (pronounced
    "see plus plus") was coined by Rick Mascitti in the summer of 1983.
    The name signifies the evolutionary nature of the changes from C; "++"
    is the C increment operator. The slightly shorter name "C+" is a
    syntax error; it has also been used as the name of an unrelated
    language. Connoisseurs of C semantics find C++ inferior to ++C. The
    language is not called D, because it is an extension of C, and it does
    not attempt to remedy problems by removing features. For yet another
    interpretation of the name C++, see the appendix of [Orwell,1949].”

    Sauce.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Difference between i++ and ++i in a loop? Is there a performance
Possible Duplicate: Is there a performance difference between i++ and ++i in C++? I
Possible Duplicate: Is there a performance difference between BETWEEN and IN with MySQL or
Possible Duplicate: Is there a performance difference between i++ and ++i in C++? They
Possible Duplicate: Is there a REAL performance difference between INT and VARCHAR primary keys?
Possible Duplicate: Is there a performance difference between i++ and ++i in C++? Is
Possible Duplicate: Is there a performance difference between i++ and ++i in C++? I
Possible Duplicate: Difference between declaring variables before or in loop? Is there any (or
Possible Duplicate: Is there a performance difference between i++ and ++i in C++? In
Possible Duplicate: Is there any particular difference between intval and (int)? These two statements

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.