C++所有“基础”头文件
2025-12-09 20:56:54
发布于:广东
本期教程(作者毕生所学)
//重点“万能头”
#include <bits/stdc++.h>
//C++基础头文件
#include <iostream> // 输入输出流(cin/cout/cerr 等),控制台输入输出核心
#include <fstream> // 文件流操作,读写文本/二进制文件(ifstream/ofstream/fstream)
#include <sstream> // 字符串流,实现字符串与基本类型的转换(istringstream/ostringstream)
#include <ios> // 输入输出流的基础格式控制(如 ios::hex/ios::fixed 等)
#include <iomanip> // 输入输出格式控制(setw/setprecision/setfill 等)
#include <vector> // 动态数组,可变长序列容器,支持随机访问
#include <list> // 双向链表,高效插入/删除,不支持随机访问
#include <deque> // 双端队列,头尾插入/删除高效,支持随机访问
#include <array> // C++11 静态数组,固定大小,比原生数组更安全
#include <set> // 有序集合(红黑树),元素唯一,自动排序
#include <unordered_set> // C++11 无序集合(哈希表),查找效率 O(1),元素唯一
#include <map> // 有序键值对映射(红黑树),键唯一,自动排序
#include <unordered_map> // C++11 无序哈希表,键值对映射,查找效率 O(1)
#include <multiset> // 有序可重复集合,允许相同元素
#include <multimap> // 有序可重复键值对映射,一个键对应多个值
#include <stack> // 栈容器(适配器),后进先出(LIFO)
#include <queue> // 队列容器(适配器),先进先出(FIFO)
#include <priority_queue> // 优先队列,默认大顶堆,按优先级出队
#include <bitset> // 位集合,高效处理二进制位操作(如位掩码)
#include <algorithm> // 通用算法库(sort/find/swap/reverse/copy 等)
#include <numeric> // 数值算法(accumulate/iota/partial_sum 等)
#include <functional> // 函数对象与绑定器(less/greater/bind/function 等)
#include <cstdlib> // 通用实用函数(malloc/free/atoi/rand/exit 等)
#include <cstdio> // C 风格输入输出(printf/scanf/fopen 等)
#include <cmath> // 数学函数(sin/cos/tan/sqrt/pow/exp/abs 等)
#include <ctime> // 时间与日期函数(time/clock/localtime 等)
#include <cstdint> // C++11 固定宽度整数类型(int8_t/uint32_t 等)
#include <cfloat> // 浮点类型特性(如 FLT_MAX/DBL_PRECISION 等)
#include <limits> // 基本类型的取值范围(numeric_limits 模板)
#include <complex> // 复数运算(complex 类,支持加减乘除/模长/辐角等)
#include <random> // C++11 随机数生成器(比 rand 更安全的随机数库)
#include <string> // C++ 字符串类(std::string),支持拼接/查找/替换等
#include <cstring> // C 风格字符串函数(strlen/strcpy/strcmp/strcat 等)
#include <cctype> // 字符分类/转换(isalpha/isdigit/toupper/tolower 等)
#include <new> // 动态内存分配(operator new/delete)
#include <memory> // 智能指针(shared_ptr/unique_ptr/weak_ptr)、内存管理
#include <typeinfo> // 运行时类型信息(typeid、dynamic_cast 支持)
#include <type_traits> // C++11 类型特性判断(is_int/is_pointer 等)
#include <exception> // 标准异常类(exception、runtime_error、logic_error 等)
#include <stdexcept> // 具体异常类型(out_of_range、invalid_argument 等)
//C++11 及以上,Dev-C++ 需配置 MinGW 支持
#include <thread> // 线程创建与管理(std::thread)
#include <mutex> // 互斥锁(std::mutex、lock_guard 等)
#include <condition_variable>// 条件变量,线程同步
#include <atomic> // 原子操作,避免数据竞争
#include <iterator> // 迭代器支持(begin/end/iterator_traits 等)
#include <utility> // 通用工具(pair、swap、move、forward 等)
#include <tuple> // C++11 元组,多值封装(std::tuple)
#include <initializer_list> // C++11 初始化列表({} 初始化支持)
#include <cassert> // 断言(assert 宏),调试用
#include <climits> // 整数类型取值范围(INT_MAX、LONG_MIN 等)
#include <cfloat> // 浮点类型取值范围(FLT_MAX、DBL_MIN 等)
#include <cstddef> // 标准定义(size_t、nullptr_t、offsetof 等)
#include <cstdio> // C 标准输入输出(printf/scanf/fopen 等)
#include <cstdlib> // C 通用工具(atoi/atof/rand/system 等)
#include <cstring> // C 字符串操作(strlen/strcpy/strcmp 等)
#include <ctime> // C 时间函数(time/clock/mktime 等)
#include <cctype> // C 字符处理(isalpha/isdigit/toupper 等)
#include <cwchar> // 宽字符处理(wchar_t、wcslen 等)
#include <cwctype> // 宽字符分类(iswalpha/iswdigit 等)
//旧版/兼容头文件(无 .h 后缀是 C++ 标准,带 .h 是 C 兼容)
// 注:C++ 中建议使用无 .h 版本(如 <cstdio> 而非 <stdio.h>)
#include <stdio.h> // C 兼容版输入输出
#include <stdlib.h> // C 兼容版通用工具
#include <string.h> // C 兼容版字符串操作
#include <math.h> // C 兼容版数学函数
#include <time.h> // C 兼容版时间函数
下期教程:
这里空空如也










有帮助,赞一个