#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
#define ABC(i) (i<=0?i:-i)
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
int j =1;
int asn;
asn = ABC(--j); //++j/j++/j--这几个可以用!
Edit1->Text = asn;
}
//---------------------------------------------------------------------------//为什么++j的结果是-3啊!谁能解释一下
在所有的 C 语言的书里面,都会着重的提示你:
不要再带参数的宏里面用z自增/自减操作符,
也不要在同一个语句里面同时使用两个或更多的自增/自减操作符。
很不幸,你同时违反了这两条建议。
如果你实在想用的话,用内联函数吧!他要安全得多。
int asn;
int j =1;
int l = --j;
asn = ABC(l); //++j/j++/j--这几个可以用!
Edit1->Text = asn;
这样吧
就没有奇怪的现象出现了
不要在带参数的宏里面用自增/自减操作符;
up