Click here to Skip to main content
15,886,963 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: what about x = x++; ? Pin
bugDanny16-Sep-05 3:15
bugDanny16-Sep-05 3:15 
GeneralRe: what about x = x++; ? Pin
pesho293216-Sep-05 3:36
pesho293216-Sep-05 3:36 
GeneralRe: what about x = x++; ? Pin
bugDanny16-Sep-05 4:19
bugDanny16-Sep-05 4:19 
GeneralRe: what about x = x++; ? Pin
pesho293218-Sep-05 21:48
pesho293218-Sep-05 21:48 
GeneralRe: what about x = x++; ? Pin
bugDanny19-Sep-05 3:02
bugDanny19-Sep-05 3:02 
GeneralRe: what about x = x++; ? Pin
pesho293219-Sep-05 5:38
pesho293219-Sep-05 5:38 
GeneralRe: what about x = x++; ? Pin
bugDanny19-Sep-05 7:43
bugDanny19-Sep-05 7:43 
GeneralRe: what about x = x++; ? Pin
pesho293219-Sep-05 21:14
pesho293219-Sep-05 21:14 
bugDanny wrote:
But of course this doesn't cover the case where b , for example, is used twice in the same expression

Indeed.

As an aside, in the statement cout << num++; there are four expressions: cout << num++, cout, num, and num++ the first one conicides with the whole statement. So I don't think the writer will refer to it several times as the statement and then use the word expression for the same thing.

Here is a quotation from C++ specification:
"It is important to note that a postfix increment or decrement expression evaluates to the value of the expression prior to application of the respective operator. The increment or decrement operation occurs after the operand is evaluated. This issue arises only when the postfix increment or decrement operation occurs in the context of a larger expression."
I think, here, it is clear what is meant by "the expression."

About x = x++; I was not sure and the question was whether you agree. Now I have a better idea thanks to David Crow ("after" does not mean "immediately after"). About y = x + x++;, I had no question. It is clear to me and I gave it as an example in which the behavior is undefined.

The difference between the two is that in the first case x++ is an operand of operator= so it has to be evaluated before operator=. (But I've come to believe that evaluation of x++ can be considered complete before the increment as there is no sequence point and the result of x++ is independent of the increment. So the increment can occur before the assignment or after.)In the second one x and x++ are the two operands of operator+ so it is not known which one the compiler will choose to evaluate first. (And if it chooses to evaluate x++ first the increment will occur at some later point and may be before or after x is evaluated.)

I'm done with this topic.WTF | :WTF:
GeneralRe: what about x = x++; ? Pin
bugDanny20-Sep-05 3:16
bugDanny20-Sep-05 3:16 
GeneralRe: what about x = x++; ? Pin
pesho293220-Sep-05 4:52
pesho293220-Sep-05 4:52 
GeneralRe: what about x = x++; ? [Modified 2005-09-19] Pin
Maxwell Chen15-Sep-05 21:17
Maxwell Chen15-Sep-05 21:17 
GeneralRe: what about x = x++; ? Pin
bugDanny16-Sep-05 3:21
bugDanny16-Sep-05 3:21 
QuestionVC++6.0 - Finding users privileges Pin
Rainos15-Sep-05 4:48
Rainos15-Sep-05 4:48 
AnswerRe: VC++6.0 - Finding users privileges Pin
David Crow15-Sep-05 7:32
David Crow15-Sep-05 7:32 
GeneralRe: VC++6.0 - Finding users privileges Pin
Rainos15-Sep-05 21:49
Rainos15-Sep-05 21:49 
GeneralRe: VC++6.0 - Finding users privileges Pin
David Crow16-Sep-05 2:11
David Crow16-Sep-05 2:11 
GeneralRe: VC++6.0 - Finding users privileges Pin
Rainos16-Sep-05 2:49
Rainos16-Sep-05 2:49 
GeneralRe: VC++6.0 - Finding users privileges Pin
David Crow16-Sep-05 4:59
David Crow16-Sep-05 4:59 
GeneralRe: VC++6.0 - Finding users privileges Pin
Rainos16-Sep-05 5:42
Rainos16-Sep-05 5:42 
GeneralRe: VC++6.0 - Finding users privileges Pin
David Crow16-Sep-05 5:48
David Crow16-Sep-05 5:48 
QuestionCTabCtrl Background in XP Themed Pin
RickyC15-Sep-05 4:15
RickyC15-Sep-05 4:15 
AnswerRe: CTabCtrl Background in XP Themed Pin
Ravi Bhavnani15-Sep-05 8:07
professionalRavi Bhavnani15-Sep-05 8:07 
GeneralRe: CTabCtrl Background in XP Themed Pin
RickyC15-Sep-05 9:39
RickyC15-Sep-05 9:39 
GeneralRe: CTabCtrl Background in XP Themed Pin
Ravi Bhavnani15-Sep-05 9:44
professionalRavi Bhavnani15-Sep-05 9:44 
GeneralRe: CTabCtrl Background in XP Themed Pin
RickyC16-Sep-05 1:39
RickyC16-Sep-05 1:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.