#include<>和#define“” [英] what is the difference between #include<> and #define""

查看:174
本文介绍了#include<>和#define“”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我#include<>和#define之间的区别。我知道#include<>用于包含头文件,#define用于定义宏或常量..它们喜欢它们不相似

  #includeabc.h
#defineabc.h
int main()
{
cout<<Hello;
return 1;

}


解决方案

#include 因为你说在实际编译之前用来包括一个文件。



#define 用于定义一个宏..如果你写 #define,它将被编译之前的值替换



<最大10

然后就在编译之前所有的max将被替换为10 ...



此外,您应参考此预处理器上的维基百科文章 / p>

Can someone tell me the difference between #include<> and #define..I know #include<> is used to include header file and #define is used to define macros or constants ..Is it like they are not similar at all?

#include"abc.h"
#define "abc.h"
int main()
{
cout<<"Hello";
return 1;

}

解决方案

#include as you said is used to include a file before the actual compilation.

#define is used to define a Macro.. that is replaced by its value just before compilation

if you write #define max 10 then just before compilation all the occurrence of "max" will be replace by the number 10...

Furthermore, you should refer to this Wikipedia article on the C preprocessor.

这篇关于#include&lt;&gt;和#define“”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆