ObjectiveIn the process-oriented language, such as C, #define is very common, and indeed useful, it is worth advocating. But in today's object-oriented languages, such as the C + + language, #define should be used sparingly.Why is it less used in C +
What this means is actually equivalent to the fact that you can replace the preprocessor with a compiler.Because using a preprocessor may make it impossible for the processed things to enter the symbol table, for example #define MaxLen 16 Here The
1. #define为预处理阶段命令Cause: It is possible that the token name did not enter the token table and a compilation error occurred, that is, the compiler did not see the definition.Class-specific const constants are generally defined as static, guaranteeing
1. Macro Definition #define Aspect_ratio 1.653The macro definition Aspect_ratio may never have been seen by the compiler, and may have been replaced by the preprocessor before the compiler started processing the source code. Therefore, the token
I. OverviewMinimize the use of preprocessor-macro substitutionSecond, details1. Constants for macro substitutionOld version: #define N 10;New version: const int n = 10;Comparison: #define不被视为语言的一部分, the tick name n is removed by the preprocessor
The difference between #define, const, typedef#define is not defining variables, it's just for text substitution.For example:#define PI 3.1415926float Angel;angel=30*pi/180;Then, when the program is compiled, the compiler will first "#define PI 3.141
1. Define (that is, host variable)The main role of the host variable is to act as an alternative variable, a medium in which the host environment can interact with Oracle . When you define a host variable by define, you must specify the variable
What do we often do with define?
1) define a constant
2) define a macro
Why do not use define. The following two aspects are explained:
1) when we define a constant, we can use the following method:
# Define aspect_patio 1.653
We know
Jency LeeLinks: http://www.cnblogs.com/Jency/articles/C_Cplusplus_define.html1. Simple define Definition #define MaxTime + A simple maxtime is defined, which represents 1000 if you write in the program if (i Compiler replaces maxtime with 1000
Thanks to http://blog.chinaunix.net/u3/111961/showart_2187819.html first
. This is an excellent article.
In the last study, we wrote a small client example, which is very simple and the header file generated by using producer-binding-tool is very
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.