The difference between #include<XXX.h> and #include "XXX.h" in C++

The difference between #include<XXX.h> and #include"XXX.h" in C++

When porting C++ code, I found:
#include
#include
#include
#include “Object.h”

The code written by my colleagues in vs is being ported to qt. Object-related classes always report errors, the header file Object.h can't be found, and I thought it was a system. After discovering the difference between #include<XXX.h> and #include"XXX.h", I realized that there is a custom Object.h was not introduced, and the file was found and the problem was solved smoothly.

The following is the explanation of a big brother:

#include<>Find the file directly from the function library that comes with the compiler.
#include"" first finds it from the customized file, if you can’t find the file, find the file from the function library

Using the "< >" method to include the header file means to let the compiler search for the corresponding header file in the compiler's preset standard path, and report an error if it cannot be found.

Special attention should be paid to the fact that if it is a standard library header file, then both the <> method and the "" method can be used, while the user-defined header file can only use the "" method.

For example, the following is correct:

#include is more efficient (look for files in the function library that comes with the compiler)

#include "iostream" is less efficient (find it from the customized file, if you can't find it, find the file from the library)

The following is incorrect:

#include <hanli.h>

hanli.h is a header file created by ourselves

Reprinted from: Thank you for the answer

Guess you like

Origin blog.csdn.net/qq_43207709/article/details/112468563