#include <iostream>
using namespace std;
void main()
{int x=5;
#define t1 x+x
#define t2 t1-t1
cout<<t1<<t2<<endl;
}
为什么结果是t1为10,t2也为10?
using namespace std;
void main()
{int x=5;
#define t1 x+x
#define t2 t1-t1
cout<<t1<<t2<<endl;
}
为什么结果是t1为10,t2也为10?
t1 - t1
x+x - x+x
所以少用宏
cout << x+x-x+x <<endl
#define t2 (t1)-(t1)
#define t2 (t1-t1)