詳解C++中的萬(wàn)能頭文件
一、什么是萬(wàn)能頭文件?
C++的萬(wàn)能頭文件是:
#include <bits/stdc++.h>
它是一個(gè)包含了每一個(gè)標(biāo)準(zhǔn)庫(kù)的頭文件。
優(yōu)點(diǎn):
- 在算法競(jìng)賽中節(jié)約時(shí)間;
- 減少了編寫所有必要頭文件的工作量。
缺點(diǎn):
- 不是GNU C++庫(kù)的標(biāo)準(zhǔn)頭文件,在部分情況下會(huì)編譯失敗;
- 包含了很多不必要的東西,會(huì)大大增加編譯時(shí)間。
二、源碼
?? 這里去除了多余的注釋,并刪除了
cstdalign
。
// C #ifndef _GLIBCXX_NO_ASSERT #include <cassert> #endif #include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #if __cplusplus >= 201103L #include <ccomplex> #include <cfenv> #include <cinttypes> #include <cstdbool> #include <cstdint> #include <ctgmath> #include <cwchar> #include <cwctype> #endif // C++ #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #if __cplusplus >= 201103L #include <array> #include <atomic> #include <chrono> #include <condition_variable> #include <forward_list> #include <future> #include <initializer_list> #include <mutex> #include <random> #include <ratio> #include <regex> #include <scoped_allocator> #include <system_error> #include <thread> #include <tuple> #include <typeindex> #include <type_traits> #include <unordered_map> #include <unordered_set> #endif
三、編譯器找不到 bits/stdc++.h
最簡(jiǎn)單粗暴的做法就是,首先找到 <iostream>
這個(gè)頭文件所在的目錄,進(jìn)入該目錄,創(chuàng)建名為 bits
的文件夾,再進(jìn)入該文件夾,創(chuàng)建一個(gè)名為 stdc++.h
的文件,把上述源碼復(fù)制進(jìn)去即可。
到此這篇關(guān)于C++中的萬(wàn)能頭文件的文章就介紹到這了,更多相關(guān)C++萬(wàn)能頭文件內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
C++11/14 線程調(diào)用類對(duì)象和線程傳參的方法
這篇文章主要介紹了C++11/14 線程調(diào)用類對(duì)象和線程傳參的方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2019-01-01關(guān)于C語(yǔ)言和命令行之間的交互問(wèn)題
這篇文章主要介紹了C語(yǔ)言和命令行之間的交互,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-07-07C語(yǔ)言線程對(duì)象和線程存儲(chǔ)的實(shí)現(xiàn)
這篇文章主要介紹了C語(yǔ)言線程對(duì)象和線程存儲(chǔ)的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2021-03-03詳解如何利用C++實(shí)現(xiàn)Mystring類
這篇文章主要為大家詳細(xì)介紹了C++實(shí)現(xiàn)MyString的示例代碼,文中通過(guò)示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-08-08C語(yǔ)言數(shù)組應(yīng)用實(shí)現(xiàn)三子棋游戲
這篇文章主要為大家詳細(xì)介紹了C語(yǔ)言數(shù)組應(yīng)用實(shí)現(xiàn)三子棋游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-06-06詳解C++虛函數(shù)中多態(tài)性的實(shí)現(xiàn)原理
C++是一種面向?qū)ο蟮木幊陶Z(yǔ)言,在C++中,虛函數(shù)是實(shí)現(xiàn)多態(tài)性的關(guān)鍵。本文就來(lái)探討一下C++虛函數(shù)中多態(tài)性的實(shí)現(xiàn)原理及其在面向?qū)ο缶幊讨械膽?yīng)用吧2023-05-05正確理解C++的構(gòu)造函數(shù)和析構(gòu)函數(shù)
在C++的學(xué)習(xí)中,可以把類當(dāng)作一個(gè)模具,類實(shí)例化出來(lái)的對(duì)象就是根據(jù)這個(gè)模具所產(chǎn)生的實(shí)體,對(duì)象看作是自己創(chuàng)建的一個(gè)新的數(shù)據(jù)類型。本文主要介紹了類對(duì)象通過(guò)拷貝函數(shù)進(jìn)行初始化,分析類對(duì)象的內(nèi)存模型,以及通過(guò)this指針實(shí)現(xiàn)更復(fù)雜的功能。最后介紹了析構(gòu)函數(shù)的基礎(chǔ)知識(shí)2021-06-06C++AVL樹(shù)4種旋轉(zhuǎn)詳講(左單旋、右單旋、左右雙旋、右左雙旋)
AVL樹(shù)即平衡二叉搜索樹(shù),平衡因子bf=右子樹(shù)的高度-左子樹(shù)的高度,bf為0,-1,1時(shí),此樹(shù)即平衡,下面這篇文章主要給大家介紹了關(guān)于C++AVL樹(shù)4種旋轉(zhuǎn)(左單旋、右單旋、左右雙旋、右左雙旋)的相關(guān)資料,需要的朋友可以參考下2022-11-11