Click here to Skip to main content
15,885,278 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CPrintDialog default printer. Pin
Maximilien22-Nov-21 1:48
Maximilien22-Nov-21 1:48 
PraiseRe: CPrintDialog default printer. Pin
Randor 22-Nov-21 2:45
professional Randor 22-Nov-21 2:45 
Question++ operator in the case of pointers Pin
Calin Negru15-Nov-21 5:32
Calin Negru15-Nov-21 5:32 
AnswerRe: ++ operator in the case of pointers Pin
Richard MacCutchan15-Nov-21 6:20
mveRichard MacCutchan15-Nov-21 6:20 
GeneralRe: ++ operator in the case of pointers Pin
Calin Negru15-Nov-21 7:10
Calin Negru15-Nov-21 7:10 
GeneralRe: ++ operator in the case of pointers Pin
Richard Andrew x6415-Nov-21 7:26
professionalRichard Andrew x6415-Nov-21 7:26 
GeneralRe: ++ operator in the case of pointers Pin
Calin Negru15-Nov-21 7:38
Calin Negru15-Nov-21 7:38 
AnswerRe: ++ operator in the case of pointers Pin
k505415-Nov-21 11:37
mvek505415-Nov-21 11:37 
You should also know about the difference between a pre-increment and post-increment operator. In an expression, a pre-increment operator computes the increment before accessing the item, and a post-increment computes the increment afterwards. For example
C++
int i = 1;
int j = ++i;   // i is incremented before assignment: i = 2, j = 2;
int k = i++;   // i is incremented after assignment: i = 3, k = 2;
int x = ++i++; // UNDEFINED BEHAVIOR!!! Do not do this!!! 
In the case ++i++ The standard does not say what will happen. The only thing you know is that i will have the value 5 after the expression is complete. The variable x could be assigned at any point during the expression, or since this is undefined behavior, it might even get the value -42, which makes no sense in respect to the code, but is acceptable according to C/C++ standard. Even if you do some testing and work out that for type int the expression ++i++ is the equivalent of ++(i++), it might be different for type long, or for a pointer type, and it might change depending on complexity of the overall expression, and/or the optimization level. The takeaway for this is that you don't know what will happen if you try to pre and post increment an expressions term at the same time. Moreover, you should not try to increment the same variable within the same expression:
C++
int i = 2;
printf("%d %d\n", i++, ++);  // undefined order of evaluation 
In the printf statement above, its undefined which order the arguments to printf get evaluated, and different compilers do it differently. I'm reasonably sure that clang and gcc do this differently.
Keep Calm and Carry On

GeneralRe: ++ operator in the case of pointers Pin
Calin Negru16-Nov-21 2:55
Calin Negru16-Nov-21 2:55 
GeneralRe: ++ operator in the case of pointers Pin
Richard MacCutchan17-Nov-21 3:02
mveRichard MacCutchan17-Nov-21 3:02 
GeneralRe: ++ operator in the case of pointers Pin
Calin Negru17-Nov-21 6:10
Calin Negru17-Nov-21 6:10 
GeneralRe: ++ operator in the case of pointers Pin
jsc4217-Nov-21 4:58
professionaljsc4217-Nov-21 4:58 
GeneralRe: ++ operator in the case of pointers Pin
k505417-Nov-21 5:20
mvek505417-Nov-21 5:20 
Questionc++ code interpreter/debugging tool Pin
Calin Negru10-Nov-21 1:40
Calin Negru10-Nov-21 1:40 
AnswerRe: c++ code interpreter/debugging tool Pin
jeron110-Nov-21 6:09
jeron110-Nov-21 6:09 
GeneralRe: c++ code interpreter/debugging tool Pin
Calin Negru10-Nov-21 7:36
Calin Negru10-Nov-21 7:36 
GeneralRe: c++ code interpreter/debugging tool Pin
jeron110-Nov-21 7:47
jeron110-Nov-21 7:47 
General[edit] Re: c++ code interpreter/debugging tool Pin
Calin Negru10-Nov-21 8:25
Calin Negru10-Nov-21 8:25 
AnswerRe: c++ code interpreter/debugging tool Pin
k505410-Nov-21 8:23
mvek505410-Nov-21 8:23 
GeneralRe: c++ code interpreter/debugging tool Pin
Calin Negru10-Nov-21 19:40
Calin Negru10-Nov-21 19:40 
GeneralRe: c++ code interpreter/debugging tool Pin
Greg Utas11-Nov-21 2:06
professionalGreg Utas11-Nov-21 2:06 
GeneralRe: c++ code interpreter/debugging tool Pin
Calin Negru11-Nov-21 2:58
Calin Negru11-Nov-21 2:58 
GeneralRe: c++ code interpreter/debugging tool Pin
Greg Utas11-Nov-21 3:15
professionalGreg Utas11-Nov-21 3:15 
GeneralRe: c++ code interpreter/debugging tool Pin
Calin Negru11-Nov-21 6:49
Calin Negru11-Nov-21 6:49 
AnswerRe: c++ code interpreter/debugging tool Pin
Randor 13-Nov-21 3:54
professional Randor 13-Nov-21 3:54 

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.