Thread: p++ and ++p priority

  1. #1
    Registered User
    Join Date
    Sep 2019
    Posts
    4

    p++ and ++p priority

    Dear all
    It is claimed that priority of post increment is more than pre increment
    May I ask show me an example?

  2. #2
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    Claimed by whom?

  3. #3
    Registered User
    Join Date
    Sep 2019
    Posts
    4
    The book of deitel

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    If by "priority" you mean "precedence" (for grouping) and by "more" you mean "higher", then the opposite is true, so you either misread the book or it contains a typo error.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User rstanley's Avatar
    Join Date
    Jun 2014
    Location
    New York, NY
    Posts
    1,111
    At one time the precedence may have been different, but they now should be considered of equal precedence. See man operator.

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by rstanley View Post
    At one time the precedence may have been different, but they now should be considered of equal precedence. See man operator.
    That's interesting, and while I can't check my copy of C11 until tomorrow, I checked a draft copy, it seems that I'm mistaken: postfix operators are listed before the unary operators, and prefix operators are listed under the latter. I thought they were listed in the major subclause before postfix operators, but that's primary expressions only. It's unlikely that this would have changed in the past ten years, so I daresay that manual entry is incomplete.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #7
    Registered User rstanley's Avatar
    Join Date
    Jun 2014
    Location
    New York, NY
    Posts
    1,111
    Quote Originally Posted by laserlight View Post
    That's interesting, and while I can't check my copy of C11 until tomorrow, I checked a draft copy, it seems that I'm mistaken: postfix operators are listed before the unary operators, and prefix operators are listed under the latter. I thought they were listed in the major subclause before postfix operators, but that's primary expressions only. It's unlikely that this would have changed in the past ten years, so I daresay that manual entry is incomplete.
    Yes, you are correct. A.2.1, in both C99 & C11.

    I stand corrected, and the manual pages should be corrected.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. XNa C# visibility priority
    By Shingetsu Kurai in forum Game Programming
    Replies: 2
    Last Post: 01-07-2012, 06:55 AM
  2. Priority Queues
    By Korhedron in forum C++ Programming
    Replies: 10
    Last Post: 07-20-2010, 10:32 AM
  3. Process priority
    By mikahell in forum Game Programming
    Replies: 5
    Last Post: 07-26-2006, 04:02 PM
  4. STL min priority queue?
    By *ClownPimp* in forum C++ Programming
    Replies: 7
    Last Post: 04-30-2006, 11:31 AM
  5. Priority
    By siavoshkc in forum Windows Programming
    Replies: 1
    Last Post: 01-18-2006, 01:57 AM

Tags for this Thread