C++中的標準程式庫(Standard Library)是类和函式的集合,其使用核心語言寫成。標準程式庫提供若干泛型容器、函式物件、泛型字串和串流(包含交互和檔案I/O),支援部分語言特性和常用的函式,如開平方根。C++標準程式庫也吸收了ISO C90 C標準程式庫。標準程式庫的特性宣告於std命名空間之中。
C++標準程式庫大量參考了並基於標準模板程式庫(STL)所建立的習慣用法,包含容器、演算法、迭代器、函式物件等。此一部分占去标准库相当大的比重,因而有些人錯誤地使用“STL”指称整个C++標準程式庫。但這並非為正確的概念,C++標準程式庫和STL共有了許多特性,但都不是彼此的超集。
使用C++標準程式庫時,不必加上「.h」。
标准头文件
以下文件包含标准库的声明。
容器
*
*
*
*
*
*
*
*
一般
*
*
*
*
*
*
*
字符串
*
输入/输出流
*
*
*
*
*
*
*
*
*
数值
*
*
*
语言支持
*
*
*
*
C标准库
来自C标准库的所有头文件,以另一个名称包含在C++标准中。將原名称移去「.h」并在开头处加上「c」作为新的名称。例如「time.h」改成「ctime」。C++标准库的头文件与C标准库的头文件的唯一区别是,函数位于std::命名空间(虽然很少编译器严格遵守,通常的做法是同时放在全局与 std 内,例如 printf 和 std::printf 两者均有)。
参见
- 标准模板库 (STL)
- Boost(C++ 库)
- C 标准库
- C POSIX
參考
- 比雅尼·斯特劳斯特鲁普:The C++ Programming Language, Addison-Wesley, ISBN 0-201-70073-5
外部链接
- [http://en.cppreference.com/w/cpp][http://en.cppreference.com/w/cpp Standard C++ Library reference]
- [http://www.cplusplus.com/reference/ C ++ reference]
- [https://web.archive.org/web/20160815222016/http://gcc.gnu.org/libstdc%20%20/ The GNU Standard C++ Library]
- [http://libcxx.llvm.org/ LLVM/Clang C++ Standard Library]
- [http://msdn2.microsoft.com/en-us/library/cscc687y(VS.140).aspx M][http://msdn2.microsoft.com/en-us/library/cscc687y(VS.140).aspx icrosoft MSDN Library - Standard C++ Library Reference]
- [https://web.archive.org/web/20070311123008/http://www.roguewave.com/support/docs/sourcepro/edition9/html/stdlibref/index.html Rogue Wave C++ Standard Library Class Reference]
- [http://msdn2.microsoft.com/en-us/library/cscc687y(VS.80).aspx Microsoft MSDN Library - Standard C++ Library Reference]
- [http://cs.stmarys.ca/~porter/csc/ref/cpp_standlib.html C++ Standard Library reference]
- [https://web.archive.org/web/20200422171727/http://cplusplus.com/ The C++ Resources Network]
- [https://www.tw511.com/2/15/347.html C++標準庫教學]
评论 (0)