-7

i know that tail_++ means that first evaluate exp using tail_ then add one ,
but what confuses me is that when it return value of tail_ "still before add",
the expression is still not finished" ,
or does it divide to two hidden expressions?"

so when it is divided by % ,
will the value of tail_be incremented or not???

i hope for answer like this:
first: tail_ is or is not incremented
second:the incremented or non incremented tail_ is divided by %
third:the array is indexed by what ever resulted in first and second
fourth:if tail_ was not incremented before and will do after array index establishment please say

thanks alot

what makes my question different is that i could not understand the impact of presence of 2 operators "++,%" with certain precedence inside same parentheses.

and then i could not understand how the expression is considered ended"does it end after each operation done?",

and in this case tail_++ with higher precedence will end first then tail_ should change value??
but this was not the case because i guess from answers that there is return object and some mysterious thing which cause the array bracket to suspend tail_++ till after getting value from array.

this is the code snippet!

data[tail_++ %maxsize]

  • 2
    `tail_++` will return `tail_`. So, `data[tail_++ % maxsize]` is actually `data[tail_ % maxsize]` and then `tail_ += 1;` – DimChtz Oct 29 '17 at 12:30
  • Possible duplicate of [Post-increment and Pre-increment concept?](https://stackoverflow.com/questions/4445706/post-increment-and-pre-increment-concept) –  Oct 29 '17 at 12:36
  • 1
    Hi @ahmed. It's a bit mean you getting -8 votes for your question. But you should improve the it's presentation by putting all your code snippets in to `code` sections - like in @DimChtz does in his/her comment. It is rather unreadable at the moment. – Annabel Oct 29 '17 at 12:51
  • I also disagree with all the downvotes. Yeah, the question isn't worded or formatted perfectly, but it's a reasonable questions. – Eli Mar 07 '19 at 09:19

1 Answers1

0

The value of the expression tail_++ is tail_.

The fact that ++ increments the value of the variable tail_ is a separate issue. The value of the expression is tail_.

Therefore the value of tail_++ % maxsize is the same as tail_ % maxsize. Just be aware that after this code executes, the value of the variable tail_ will have incremented.

Eli
  • 693
  • 5
  • 12