The #define Directive
When you compile a program the  compiler first uses a preprocessor to analyze the code. The #define  directive can be used to either define a constant number or function or  to replace an instruction in your code.  For instance: 
#define for_ever_do while(1)
#define sqr(x) (x*x)
#define conc(a,b)
int main() {
int xyz=123,try=125;
cout<<conc(xy,z)<<" "<<conc(t,ry);
}
This will display 123 125 because the preprocessor replaces conc(xy,z) with xyz and then evaluates it.  
 
No comments:
Post a Comment