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

  • Home
  • SEARCH
  • 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 6081841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:13:16+00:00 2026-05-23T11:13:16+00:00

When someone asks about the difference between post-increment/decrement and pre-increment/decrement, the response is usually

  • 0

When someone asks about the difference between post-increment/decrement and pre-increment/decrement, the response is usually that the prefix versions add one to the variable and return the new value of the variable whereas the postfix versions add one to the variable and return the old value.

While messing around, I found out that all of these lines are legal:

int i = 1;
++i;
++++++++++++++i;
(++++++++++++++i)++;
(++++++(++++(++i)))++;
------i;
--++++--++----++i;
i+=++++++++++++++i+i++-i--; 

But none of the following lines are legal:

i++++;
++i++;
--i--;

If I assume that the prefix versions return by reference, this all makes sense (even the last example because postfix has higher precedence than prefix).

Is the assumption/realization that the prefix versions return a reference and the postfix versions return a value correct? Are there any other subtle behavior differences that I don’t know about for the pre/post inc/decrement operators?

  • 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-05-23T11:13:17+00:00Added an answer on May 23, 2026 at 11:13 am

    In C++, the prefix increment/decrement expressions “return” lvalues and the postfix versions return rvalues. In C both forms return rvalues.

    However, be aware that the behavior is undefined if you try to writing to a variable more than once between two sequence points. So the distinction doesn’t really matter anyway.

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

Sidebar

Related Questions

I want to build a bot that asks someone a few simple questions and
Someone told me about a C++ style difference in their team. I have my
Someone told me about swamp diagrams explaning that they were useful to predict code
read many posts about the difference between the 3 idioms. But got more confused,
I've got a couple open-source projects on Codeplex (I'll link if someone asks, but
Someone told me that it's faster to concatenate strings with StringBuilder. I have changed
Someone asked me a question via e-mail about integer partitions the other day (as
I am looking at a practice test that doesn't have explanations about the correct
So when someone asks you to give a O(n) or a O(nlogn) algorithm to
I need to return values, and when someone asks for a value, tell them

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.