apparently, define statements (#define) are simply a search and replace. (pre-compiled)
the example used in class was:
#define sum a+b
anywhere in the program where sum is found, its value will be replaced by a+b.
another use of the define statement, would be the use for macros and they are generally preferred to be one liners
i.e.
#define sum(x,y) ((x)+(y))
it is essentially a function; anywhere sum(x,y) is found, the values in found as the parameters will be summed up.
*keep in mind, that when there are '#', that those should be 'compiled' first; there are essentially '2 walkthroughs when looking at a program with precompiled code'
Wednesday, January 27, 2010
Tuesday, January 12, 2010
Subscribe to:
Posts (Atom)