++i和i++有什么本质区别?

You don't need to ask others everywhere,
you'd better write a code and debug it,
then you will find the answer by yourself.

// x.cpp : Defines the entry point for the console application.
//

include "stdafx.h"

int _tmain(int argc, _TCHAR* argv[])
{
int i,j,x,y;

 i = 0;
 j = 0;

 ++i;

 j++;

 x = ++i;

 y = j++;

 return 0;

}


 ++i;

009D137C mov eax,dword ptr [i]
009D137F add eax,1
009D1382 mov dword ptr [i],eax

 j++;

009D1385 mov eax,dword ptr [j]
009D1388 add eax,1
009D138B mov dword ptr [j],eax

 x = ++i;

009D138E mov eax,dword ptr [i]
009D1391 add eax,1
009D1394 mov dword ptr [i],eax
009D1397 mov ecx,dword ptr [i]
009D139A mov dword ptr [x],ecx

 y = j++;

009D139D mov eax,dword ptr [j]
009D13A0 mov dword ptr [y],eax
009D13A3 mov ecx,dword ptr [j]
009D13A6 add ecx,1
009D13A9 mov dword ptr [j],ecx

posted @ 2022-10-28 18:35  ChrainY  阅读(47)  评论(0编辑  收藏  举报