Analysis of #include usage in c++

Here you need to pay attention to two different ways of writing include, #include<***.h> and #include"***.h"

Using the "< >" method to include the header bai 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 .
For example: VS2008 installation directory \Microsoft Visual Studio 9.0\VC\include contains the header files of the standard library.

The second method means to search under the path where the project is located first, and if it fails, search under the standard path of the system .
Therefore, it is particularly important to note 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 <iostream> is more efficient
#include "iostream" is less efficient

The following way is incorrect:
#include<diy.h> diy.h is the header file created by ourselves
. The format in the installation problem, all the files that can be added are as follows:

A. Traditional C++:

#include <assert.h> //Set insertion point
#include <ctype.h> //Character processing
#include <errno.h> //Define error code
#include <float.h> //Floating point number processing
#include <fstream.h> //File input/output
#include <iomanip.h> //Parameterized input/output
#include <iostream.h> //Data stream input/output
#include <limits.h> //Define each The most value constants of various data types
#include <locale.h> //Define localization functions
#include <math.h> //Define mathematical functions
#include <stdio.h> //Define input/output functions
#include <stdlib. h> //define miscellaneous functions and memory allocation functions
#include <string.h> //string processing
#include <strstrea.h> //array-based input/output
#include <time.h> //define about time function
#include <wchar.h> // wide-character processing and input / output
#include <wctype.h> // wide character classification

B. Standard C++ (The same file as above is no longer commented)

#include <algorithm> //STL general algorithm
#include <bitset> //STL bit set container
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex> //plural
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque> //STL double-ended queue container
#include <exception> //Exception handling class
#include <fstream>
#include < functional> //STL defines arithmetic functions (instead of operators)
#include <limits>
#include <list> //STL linear list container
#include <map> //STL mapping container
#include <iomanip>
#include <ios> / /Basic Input/Output Support
#include <iosfwd> //Pre-declaration used by the input/output system
#include <iostream>
#include <istream> //Basic input stream
#include <ostream> //Basic output stream
#include <queue> //STL queue container
#include <set> //STL collection container
#include <sstream> //string-based stream
#include <stack> //STL Stack container
#include <stdexcept> //Standard exception class
#include <streambuf> // Low- level input/output support
#include <string> //String class
#include <utility> //STL general template class
#include <vector> //STL dynamic array container
#include <cwchar>
#include <cwctype>

C, C99 added:

#include <complex.h> //Complex number processing
#include <fenv.h> //Floating point environment
#include <inttypes.h> //Integer format conversion
#include <stdbool.h> //Boolean environment
#include <stdint .h> //Integer environment
#include <tgmath.h> //General type math macro

Guess you like

Origin blog.csdn.net/Dust_Evc/article/details/114259374