-

2011年8月4日星期四

What will happen when i assign a value the #define function in C++?

-The #define directive identifies identifier as a MACRO

=

#define identifier replacement-list

- whenever identifier is encountered as a token, it is replaced by replacement-list#define is a preprocessor directive that's used to help programmers save time and make clearer code by not having to write the same code over and over.

For example, if you have the following:

#define MAX 100

that means all occurrences of "MAX" (case sensitive) will be replaced with 100.

That line is equal to:

const MAX = 100;



To learn more, see:

http://cplusplus.com/doc/tutorial/prepro鈥?/a>

http://wikipedia.org/wiki/C_preprocessor
If you used for example "#define SIZE 10", that means that wherever you write "SIZE" in the program this will be seen by the compiler as the value 10.

没有评论:

发表评论