Click here to Skip to main content
15,920,896 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Dll Linking problem Pin
KingsGambit22-Feb-10 20:52
KingsGambit22-Feb-10 20:52 
QuestionC++ Pin
Pankaj D.Dubey22-Feb-10 17:41
Pankaj D.Dubey22-Feb-10 17:41 
AnswerRe: C++ Pin
KingsGambit22-Feb-10 18:00
KingsGambit22-Feb-10 18:00 
GeneralRe: C++ Pin
Pankaj D.Dubey22-Feb-10 18:02
Pankaj D.Dubey22-Feb-10 18:02 
GeneralRe: C++ Pin
KingsGambit22-Feb-10 18:11
KingsGambit22-Feb-10 18:11 
GeneralRe: C++ Pin
Pankaj D.Dubey22-Feb-10 18:13
Pankaj D.Dubey22-Feb-10 18:13 
GeneralRe: C++ Pin
KingsGambit22-Feb-10 18:20
KingsGambit22-Feb-10 18:20 
AnswerRe: C++ PinPopular
Avi Berger22-Feb-10 18:21
Avi Berger22-Feb-10 18:21 
Pankaj D.Dubey wrote:
int i = 2;

i = ++i + (++i)

cout<<i;

logically the="" code="" should="" print="" value="" '7'="" but="" i="" am="" getting="" '8'="" as="" output.
why="" is="" it="" so?
<="" blockquote="">

Actually, 8 is just as a correct answer as 7. To research this, search for the term "sequence points".

In ++i + (++i) for each ++i, i is first incremented, then the value is used. Also, the add will be done last. This does not fully define the order of evaluation of everything - and the implementation is free to choose the rest of the order.

So it could do things in the order you were thinking of. Another equally valid order is:
do the first increment ( i gets 3),
do the second increment ( i gets 4 ),
add current i to current i (8)

The bottom line is that you shouldn't write expressions where parts of the expression have side effects that could alter the value of other parts of the expression.
Please do not read this signature.

GeneralRe: C++ Pin
Pankaj D.Dubey22-Feb-10 18:30
Pankaj D.Dubey22-Feb-10 18:30 
GeneralRe: C++ [modified] Pin
Avi Berger22-Feb-10 18:43
Avi Berger22-Feb-10 18:43 
GeneralRe: C++ Pin
Pankaj D.Dubey22-Feb-10 18:50
Pankaj D.Dubey22-Feb-10 18:50 
AnswerRe: C++ Pin
«_Superman_»22-Feb-10 19:26
professional«_Superman_»22-Feb-10 19:26 
GeneralRe: C++ Pin
Avi Berger22-Feb-10 19:51
Avi Berger22-Feb-10 19:51 
GeneralRe: C++ Pin
Peter_in_278022-Feb-10 20:52
professionalPeter_in_278022-Feb-10 20:52 
GeneralRe: C++ Pin
KingsGambit22-Feb-10 21:03
KingsGambit22-Feb-10 21:03 
GeneralRe: C++ Pin
Peter Weyzen23-Feb-10 10:25
Peter Weyzen23-Feb-10 10:25 
GeneralRe: C++ Pin
Avi Berger23-Feb-10 6:34
Avi Berger23-Feb-10 6:34 
QuestionAbout array of BSTR Pin
eight22-Feb-10 16:48
eight22-Feb-10 16:48 
AnswerRe: About array of BSTR Pin
«_Superman_»22-Feb-10 17:01
professional«_Superman_»22-Feb-10 17:01 
QuestionGDI+ Problem! Pin
mostafa_pasha22-Feb-10 11:44
mostafa_pasha22-Feb-10 11:44 
AnswerRe: GDI+ Problem! Pin
Richard Andrew x6422-Feb-10 13:55
professionalRichard Andrew x6422-Feb-10 13:55 
GeneralRe: GDI+ Problem! Pin
LunaticFringe22-Feb-10 13:56
LunaticFringe22-Feb-10 13:56 
GeneralRe: GDI+ Problem! Pin
Richard Andrew x6422-Feb-10 13:58
professionalRichard Andrew x6422-Feb-10 13:58 
AnswerRe: GDI+ Problem! Pin
LunaticFringe22-Feb-10 13:55
LunaticFringe22-Feb-10 13:55 
GeneralRe: GDI+ Problem! Pin
mostafa_pasha22-Feb-10 18:51
mostafa_pasha22-Feb-10 18:51 

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.