Click here to Skip to main content
15,562,903 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CPrintDialog default printer. Pin
Maximilien22-Nov-21 2:48
Maximilien22-Nov-21 2:48 
PraiseRe: CPrintDialog default printer. Pin
Randor 22-Nov-21 3:45
professional Randor 22-Nov-21 3:45 
Question++ operator in the case of pointers Pin
Calin Negru15-Nov-21 6:32
Calin Negru15-Nov-21 6:32 
AnswerRe: ++ operator in the case of pointers Pin
Richard MacCutchan15-Nov-21 7:20
mveRichard MacCutchan15-Nov-21 7:20 
GeneralRe: ++ operator in the case of pointers Pin
Calin Negru15-Nov-21 8:10
Calin Negru15-Nov-21 8:10 
GeneralRe: ++ operator in the case of pointers Pin
Richard Andrew x6415-Nov-21 8:26
professionalRichard Andrew x6415-Nov-21 8:26 
GeneralRe: ++ operator in the case of pointers Pin
Calin Negru15-Nov-21 8:38
Calin Negru15-Nov-21 8:38 
AnswerRe: ++ operator in the case of pointers Pin
k505415-Nov-21 12:37
mvek505415-Nov-21 12: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 3:55
Calin Negru16-Nov-21 3:55 
GeneralRe: ++ operator in the case of pointers Pin
Richard MacCutchan17-Nov-21 4:02
mveRichard MacCutchan17-Nov-21 4:02 
GeneralRe: ++ operator in the case of pointers Pin
Calin Negru17-Nov-21 7:10
Calin Negru17-Nov-21 7:10 
GeneralRe: ++ operator in the case of pointers Pin
jsc4217-Nov-21 5:58
professionaljsc4217-Nov-21 5:58 
GeneralRe: ++ operator in the case of pointers Pin
k505417-Nov-21 6:20
mvek505417-Nov-21 6:20 
Questionc++ code interpreter/debugging tool Pin
Calin Negru10-Nov-21 2:40
Calin Negru10-Nov-21 2:40 
AnswerRe: c++ code interpreter/debugging tool Pin
jeron110-Nov-21 7:09
jeron110-Nov-21 7:09 
GeneralRe: c++ code interpreter/debugging tool Pin
Calin Negru10-Nov-21 8:36
Calin Negru10-Nov-21 8:36 
GeneralRe: c++ code interpreter/debugging tool Pin
jeron110-Nov-21 8:47
jeron110-Nov-21 8:47 
General[edit] Re: c++ code interpreter/debugging tool Pin
Calin Negru10-Nov-21 9:25
Calin Negru10-Nov-21 9:25 
AnswerRe: c++ code interpreter/debugging tool Pin
k505410-Nov-21 9:23
mvek505410-Nov-21 9:23 
GeneralRe: c++ code interpreter/debugging tool Pin
Calin Negru10-Nov-21 20:40
Calin Negru10-Nov-21 20:40 
GeneralRe: c++ code interpreter/debugging tool Pin
Greg Utas11-Nov-21 3:06
mveGreg Utas11-Nov-21 3:06 
GeneralRe: c++ code interpreter/debugging tool Pin
Calin Negru11-Nov-21 3:58
Calin Negru11-Nov-21 3:58 
GeneralRe: c++ code interpreter/debugging tool Pin
Greg Utas11-Nov-21 4:15
mveGreg Utas11-Nov-21 4:15 
GeneralRe: c++ code interpreter/debugging tool Pin
Calin Negru11-Nov-21 7:49
Calin Negru11-Nov-21 7:49 
AnswerRe: c++ code interpreter/debugging tool Pin
Randor 13-Nov-21 4:54
professional Randor 13-Nov-21 4: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.