※C++随笔※=>☆C++基础☆=>※№→C++中 #include<>与#include""

#include<>

        使用尖括号表示在包含文件目录中去查找(包含目录是由用户在设置环境时设置的),而不在源文件目录去查找; 


#include""

        使用双引号则表示首先在当前的源文件目录中查找,若未找到才到包含目录中去查找;


MSDN的相关说明
        #include""
                This form instructs the preprocessor to look for include files in the same directory of the file that contains the #include statement, and then in the directories of any files that include (#include) that file. The preprocessor then searches along the path specified by the /I compiler option, then along paths specified by the INCLUDE environment variable.

        #include<>
                This form instructs the preprocessor to search for include files first along the path specified by the /I compiler option, then, when compiling from the command line, along the path specified by the INCLUDE environment variable.


扩展知识

1. 

        Q:C++中的预处理#include<iostream>和#include<iostream.h>对程序的运行有什么不同?

        A:没有区别

2. 

        Q:#include<iostream>后加using namespace std; 和直接用#include<iostream.h>在运行上有什么区别?

        A:#include<iostream.h>是早些时候的形式

                最新的标准定义的是
                #include<iostream>
                using namespace std;

                比如#include<math.h>变成
                #include<cmath>
                using namespace std;
 
                #include<string.h>变成
                #include<cstring>
                using namespace std;


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
以后的笔记潇汀会尽量详细讲解一些相关知识的,希望大家继续关注我的博客。
本节笔记到这里就结束了。


潇汀一有时间就会把自己的学习心得,觉得比较好的知识点写出来和大家一起分享。
游戏开发的路很长很长,非常希望能和大家一起交流,共同学习,共同进步。
如果文章中有什么疏漏的地方,也请大家指正。也希望大家可以多留言来和我探讨编程相关的问题。
最后,谢谢你们一直的支持~~~

原文地址:https://www.cnblogs.com/suncoolcat/p/3362214.html