/*** book: "thinkinginc++" * Function: about the use of macros, explore the disadvantages of using macros * Time: September 11, 2014 07:50:54* Author: cutter_point*/#include ". /require.h "#include <fstream>using namespace std;//here is to use BAND (x) instead of the following string of functions # define BAND (x) (((x) >5 && (x) <10)? (x): 0) int main () { ofstream out ("Macro.txt"); Assure (out, "macro.txt"); for (int i=4; i < one; ++i) { int a=i; out<< "a=" <<a<<endl<< ' t '; Be careful here, remember to use the macro instead of the result expansion should be like this //(((++a) >5 && (++a) <10)? (++a): 0) Call three times ++a, //OK, once the code is executed, the problem is immediately reflected out<< "BAND (++a) =" <<band (++a) <<endl; out<< "\ a=" <<a<<endl; } return 0;} /* Execution Result: a= 4BAND (++a) =0 a=5a= 5BAND (++a) =8 a=8a= 6BAND (++a) =9 a=9a= 7BAND (++a) =10 a=10a= 8BAND (++a) =0 a=10a= 9BAND (++a) =0 A =11a= 10BAND (++a) =0 a=12*/
"Thinkinginc++" 47, about the use of macros, explore the disadvantages of using macros