此段程序的输出结果本帖最后由 softpart 于 2012-11-19 16:23:15 编辑请教一个问题:#include stdafx.h#i
此段程序的输出结果
本帖最后由 softpart 于 2012-11-19 16:23:15 编辑 请教一个问题:
#include "stdafx.h"
#include <iostream>
#define DIS(x1, x2) ((x2) - (x1)) ;
int _tmain(int argc, _TCHAR* argv[])
{
int i = 0 ;
i = DIS(1, 2) - DIS(1, 4) ;
int j = 0;
j = DIS(1, 4);
std::cout << " i = " << i << ", j= "<<j<<std::endl;
system("pause");
return 0;
}
为什么输出结果是:i=1,j=3?
[解决办法]
i=1是因为#define多了一个引号
j=3是因为4-1;
