Nature macro definition

Macro definition of nature:

Character replacement, no type conversion, you must remember

Look at an example:

#include<bits/stdc++.h>
using namespace std;

#define AREA(a,b) a+b

int main()
{
	int s=AREA(3,4)*AREA(3,4);
	cout << s << endl;
	return 0;
}

  Will the output answer is how much?

You might say 49, fooled brothers

The answer is 19, said the character is replaced so

AREA (3,4) returns an answer but not a character to replace 3 + 4 
then
s = AREA (3,4) * AREA (3,4) is equivalent to s = 3 + 4 * 3 + 4 
so the result is 19

Guess you like

Origin www.cnblogs.com/mch5201314/p/11919308.html