current position:Home>C + +, please do me a favor,

C + +, please do me a favor,

2022-01-27 01:43:27 CSDN Q & A

C++ in fun What does function mean ?++i and i++ How to use it? , In the program, it should +1 Or not +1 Well




Refer to the answer 1:

++i When it's time to execute ++i, Then execute other expressions
i++ When , Execute other expressions first , Finally, execute i++
Illustrate with examples :
int a ,b;
int i = 1;
a = i++;
here , Execute first a = i,a The value of is 1, And then execute i++;
b = ++i;
here , Execute first ++i,i The value of the into 3(a=i++ after ,i Value =2, Here again ++, Namely 3), therefore b The value of is 3




Refer to the answer 2:



Refer to the answer 3:

C++ in fun What does function mean ?++i and i++ How to use it? , In the program, it should +1 Or not +1 Well
Your question is a little confused
Where is the code ? Function not visible , How do I know you fun What does function mean
++i yes i First plus 1 Reuse ,i++ yes i First use and then add 1
Which one to use , It depends on your functional needs




Refer to the answer 4:



Refer to the answer 5:

int i=1;
int a=i++;// At this point, output i, then i add 1, therefore ,a Namely 1
int b=++i;// At this point, first perform i Add 1, Then the output i, therefore ,a Namely 2




Refer to the answer 6:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201270143255107.html

Random recommended