⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lib_cpp.html

📁 ST20 Embedded Toolset R2.0.5用于开发基于ST20芯片机顶盒软件的开发平台,2.0.5版本,国内找不到的.在国外论坛上花了N天才找到!
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<HTML><HEAD><TITLE>C++ Library Overview</TITLE></HEAD><BODY><H1><A NAME="C++ Library Overview">C++ Library Overview</A></H1><HR><P><B><A HREF="#Using C++ Library Headers">Using C++ Library Headers</A>&#183; <A HREF="#C++ Library Conventions">C++ Library Conventions</A>&#183; <A HREF="#iostreams">Iostreams Conventions</A>&#183; <A HREF="#C++ Program Startup and Termination">ProgramStartup and Termination</A></B></P><P>All C++ library entities are declared or defined in one or more<A HREF="lib_over.html#standard headers">standard headers</A>.To make use of a library entity in a program, write an<A HREF="preproc.html#include directive"><I>include</I> directive</A>that names the relevant standard header.The Standard C++ library consists of 51 required headers.This <A HREF="index.html#implementation">implementation</A> also includesthree additional headers, <CODE>&lt;hash_map&gt;</CODE>,<CODE>&lt;hash_set&gt;</CODE>,and <CODE>&lt;slist&gt;</CODE>, not required by the C++ Standard,for a total of 54 headers.These 54<B><A NAME="C++ library headers">C++ library headers</A></B>(along with the additional 18<A HREF="lib_over.html#standard headers">Standard C headers</A>)constitute a<B><A NAME="hosted implementation">hosted implementation</A></B>of the C++ library:<CODE><A HREF="algorith.html">&lt;algorithm&gt;</A></CODE>,<CODE><A HREF="bitset.html">&lt;bitset&gt;</A></CODE>,<CODE><A HREF="cassert.html">&lt;cassert&gt;</A></CODE>,<CODE><A HREF="cctype.html">&lt;cctype&gt;</A></CODE>,<CODE><A HREF="cerrno.html">&lt;cerrno&gt;</A></CODE>,<CODE><A HREF="cfloat.html">&lt;cfloat&gt;</A></CODE>,<CODE><A HREF="ciso646.html">&lt;ciso646&gt;</A></CODE>,<CODE><A HREF="climits.html">&lt;climits&gt;</A></CODE>,<CODE><A HREF="clocale.html">&lt;clocale&gt;</A></CODE>,<CODE><A HREF="cmath.html">&lt;cmath&gt;</A></CODE>,<CODE><A HREF="complex.html">&lt;complex&gt;</A></CODE>,<CODE><A HREF="csetjmp.html">&lt;csetjmp&gt;</A></CODE>,<CODE><A HREF="csignal.html">&lt;csignal&gt;</A></CODE>,<CODE><A HREF="cstdarg.html">&lt;cstdarg&gt;</A></CODE>,<CODE><A HREF="cstddef.html">&lt;cstddef&gt;</A></CODE>,<CODE><A HREF="cstdio.html">&lt;cstdio&gt;</A></CODE>,<CODE><A HREF="cstdlib.html">&lt;cstdlib&gt;</A></CODE>,<CODE><A HREF="cstring.html">&lt;cstring&gt;</A></CODE>,<CODE><A HREF="ctime.html">&lt;ctime&gt;</A></CODE>,<CODE><A HREF="cwchar.html">&lt;cwchar&gt;</A></CODE>,<CODE><A HREF="cwctype.html">&lt;cwctype&gt;</A></CODE>,<CODE><A HREF="deque.html">&lt;deque&gt;</A></CODE>,<CODE><A HREF="exceptio.html">&lt;exception&gt;</A></CODE>,<CODE><A HREF="fstream.html">&lt;fstream&gt;</A></CODE>,<CODE><A HREF="functio2.html">&lt;functional&gt;</A></CODE>,<CODE><A HREF="hash_map.html">&lt;hash_map&gt;</A></CODE>,<CODE><A HREF="hash_set.html">&lt;hash_set&gt;</A></CODE>,<CODE><A HREF="iomanip.html">&lt;iomanip&gt;</A></CODE>,<CODE><A HREF="ios.html">&lt;ios&gt;</A></CODE>,<CODE><A HREF="iosfwd.html">&lt;iosfwd&gt;</A></CODE>,<CODE><A HREF="iostream.html">&lt;iostream&gt;</A></CODE>,<CODE><A HREF="istream.html">&lt;istream&gt;</A></CODE>,<CODE><A HREF="iterator.html">&lt;iterator&gt;</A></CODE>,<CODE><A HREF="limits2.html">&lt;limits&gt;</A></CODE>,<CODE><A HREF="list.html">&lt;list&gt;</A></CODE>,<CODE><A HREF="locale2.html">&lt;locale&gt;</A></CODE>,<CODE><A HREF="map.html">&lt;map&gt;</A></CODE>,<CODE><A HREF="memory.html">&lt;memory&gt;</A></CODE>,<CODE><A HREF="new.html">&lt;new&gt;</A></CODE>,<CODE><A HREF="numeric.html">&lt;numeric&gt;</A></CODE>,<CODE><A HREF="ostream.html">&lt;ostream&gt;</A></CODE>,<CODE><A HREF="queue.html">&lt;queue&gt;</A></CODE>,<CODE><A HREF="set.html">&lt;set&gt;</A></CODE>,<CODE><A HREF="slist.html">&lt;slist&gt;</A></CODE>,<CODE><A HREF="sstream.html">&lt;sstream&gt;</A></CODE>,<CODE><A HREF="stack.html">&lt;stack&gt;</A></CODE>,<CODE><A HREF="stdexcep.html">&lt;stdexcept&gt;</A></CODE>,<CODE><A HREF="streambu.html">&lt;streambuf&gt;</A></CODE>,<CODE><A HREF="string2.html">&lt;string&gt;</A></CODE>,<CODE><A HREF="strstrea.html">&lt;strstream&gt;</A></CODE>,<CODE><A HREF="typeinfo.html">&lt;typeinfo&gt;</A></CODE>,<CODE><A HREF="utility.html">&lt;utility&gt;</A></CODE>,<CODE><A HREF="valarray.html">&lt;valarray&gt;</A></CODE>, and<CODE><A HREF="vector.html">&lt;vector&gt;</A></CODE>.</P><P>A <B><A NAME="freestanding implementation">freestanding implementation</A></B>of the C++ library provides only a subset of these headers:<CODE><A HREF="cstddef.html">&lt;cstddef&gt;</A></CODE>,<CODE><A HREF="cstdlib.html">&lt;cstdlib&gt;</A></CODE>(declaring at least the functions<A HREF="stdlib.html#abort"><CODE>abort</CODE></A>,<A HREF="stdlib.html#atexit"><CODE>atexit</CODE></A>, and<A HREF="stdlib.html#exit"><CODE>exit</CODE></A>),<CODE><A HREF="exceptio.html">&lt;exception&gt;</A></CODE>,<CODE><A HREF="limits2.html">&lt;limits&gt;</A></CODE>,<CODE><A HREF="new.html">&lt;new&gt;</A></CODE>,<CODE><A HREF="typeinfo.html">&lt;typeinfo&gt;</A></CODE>, and<CODE><A HREF="cstdarg.html">&lt;cstdarg&gt;</A></CODE>.</P><P>The C++ library headers have two broader subdivisions,<A HREF="#iostreams">iostreams</A> headers and<A HREF="index.html#STL">STL</A> headers.</P><H2><A NAME="Using C++ Library Headers">Using C++ Library Headers</A></H2><P>You include the contents of a standard header by naming it in an<A HREF="preproc.html#include directive"><I>include</I> directive</A>,as in:</P><PRE>#include &lt;iostream&gt;  /* include I/O facilities */</PRE><P>You can include the standard headers in any order, a standardheader more than once, or two or more standard headers that definethe same macro or the same type.Do not include a standard header within a declaration. Do notdefine macros that have the same names as keywords before you includea standard header.</P><P>A C++ library header includes any other C++ library headersit needs to define needed types. (Always include explicitly anyC++ library headers needed in a translation unit, however, lestyou guess wrong about its actual dependencies.) A Standard C headernever includes another standard header. A standard header declaresor defines only the entities described for it in this document.</P><P>Every function in the library is declared in a standard header.Unlike in Standard C, the standard header never provides a<A HREF="lib_over.html#masking macro">masking macro</A>,with the same name as the function, that masks the functiondeclaration and achieves the same effect.</P><P>All names other than <CODE>operator delete</CODE> and<CODE>operator new</CODE> in the C++ library headers are defined in the<B><CODE><A NAME="std namespace">std</A></CODE></B> namespace,or in a namespace nested within the <CODE>std</CODE> namespace.You refer to the name<CODE><A HREF="iostream.html#cin">cin</A></CODE>, for example,as <CODE>std::cin</CODE>. Note, however, that macro names are not subject tonamespace qualification, so you always write<CODE><A HREF="complex.html#__STD_COMPLEX">__STD_COMPLEX</A></CODE>without a namespace qualifier.</P><P>In some translation environments, including a C++ library headermay hoist external names declared in the <CODE>std</CODE> namespaceinto the global namespace as well, with individual <I>using</I>declarations for each of the names. Otherwise, the header does<I>not</I> introduce any library names into the current namespace.</P><P>The C++ Standard requires that the<A HREF="lib_over.html#standard headers">C Standard headers</A> declareall external names in namespace <CODE>std</CODE>, then hoist them intothe global namespace with individual <I>using</I> declarationsfor each of the names.But in some translation environments the C Standard headersinclude no namespace declarations,declaring all names directly in the global namespace.Thus, the most portable way to deal with namespaces is to followtwo rules:</P><UL><LI>To assuredly declare in namespace <CODE>std</CODE>an external name that is traditionally declaredin <CODE>&lt;stdlib.h&gt;</CODE>, for example,include the header <CODE>&lt;cstdlib&gt;</CODE>. Know thatthe name might also be declared in the global namespace.</LI><LI>To assuredly declare in the global namespacean external name declared in <CODE>&lt;stdlib.h&gt;</CODE>,include the header <CODE>&lt;stdlib.h&gt;</CODE> directly. Know thatthe name might also be declared in namespace <CODE>std</CODE>.</LI></UL><P>Thus, if you want to call<CODE>std::<A HREF="stdlib.html#abort">abort</A>()</CODE>to cause abnormal termination,you should include <CODE>&lt;cstdlib&gt;</CODE>.And if you want to call <CODE>abort()</CODE>,you should include<CODE>&lt;stdlib.h&gt;</CODE>.</P><P>Alternatively, you can write the declaration:</P><PRE>using namespace std;</PRE><P>which assuredly hoists all library names into the current namespace.If you write this declaration immediately after all <I>include</I>directives, you hoist the names into the global namespace.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -