让我们尝试下面的实例:
实例
#include<iostream>usingnamespacestd;#defineDEBUG#defineMIN(a,b)(((a)<(b)) ? a : b)intmain(){ inti, j; i = 100; j = 30;#ifdefDEBUG cerr <<"Trace: Inside main function" << endl;#endif#if0 /* 这是注释部分 */ cout << MKSTR(HELLOC++) << endl;#endif cout <<"The minimum is " << MIN(i, j) << endl; #ifdefDEBUG cerr <<"Trace: Coming out of main function" << endl;#endif return0;}
当上面的代码被编译和执行时,它会产生下列结果:
Trace:Inside main function
The minimum is30
Trace:Comingout of main function