Back
Featured image of post i++与++i

i++与++i

i++与++i

i++: 后加加, 先自增,然后返回自增之前的值

++i: 前加加, 先自增,然后返回自增之后的值

总结: 不管i++还是++i,运算之后,i 本身的值都自增,(i++)整体不增,++i 整体增

int i= 1;

i++后: (i++) = 1  ;  i = 2

++i后: (++i) = 2  ;  i = 2
承认自己的无知 , 乃是开启智慧的大门
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy