define总结-define用法集锦网上资料汇集-希望对您有帮助.docVIP

  • 4
  • 0
  • 约6.77千字
  • 约 11页
  • 2018-01-19 发布于浙江
  • 举报

define总结-define用法集锦网上资料汇集-希望对您有帮助.doc

define总结-define用法集锦网上资料汇集-希望对您有帮助

? #define总结-#define用法集锦 (网上资料汇集) The #define Directive   You can use the #define directive to give a meaningful name to a constant in your program. The two forms of the syntax are:   Syntax   #define identifier token-stringopt   #define identifier[( identifieropt, ... , identifieropt )] token-stringopt Usage: 1. 简单的define定义 #define MAXTIME 1000 一个简单的MAXTIME就定义好了,它代表1000,如果在程序里面写 if(iMAXTIME){.........} 编译器在处理这个代码之前会对MAXTIME进行处理替换为1000。 这样的定义看起来类似于普通的常量定义CONST,但也有着不同,因为define的定义更像是简单的文本替换,而不是作为一个量来使用,这个问题在下面反映的尤为突出。 2.define的“函数定义” define可以像函数那样接受一些参数,如下 #define max(x,y) (x)(y)?(x):

文档评论(0)

1亿VIP精品文档

相关文档