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

📄 cppstack_details.html

📁 ssd5 数据结构的课件
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>  <head>    <meta name="generator" content="HTML Tidy for Linux/x86 (vers 1st October 2002), see www.w3.org">    <title>C++ Stacks</title>  </head>  <body bgcolor="#ffffff">    <table width="100%" bgcolor="#eeeeff">      <tr>        <td><a href="index.html">cppreference.com</a> -&gt; <a href="cppstack.html">C++ Stacks</a> -&gt;        Details</td>      </tr>    </table>    <h1>C++ Stacks</h1>    <hr>    <h2><a name="Operators">Operators</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  ==  &lt;=  &gt;=  &lt;  &gt;  !=</pre>        </td>      </tr>    </table>    <p>All of the above operators can be used on stacks. Equality is defined by stacks having the same    elements in the same order.</p>    <hr>    <h2><a name="empty">empty</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  bool empty();</pre>        </td>      </tr>    </table>    <p>The empty() function returns <strong>true</strong> if the current stack is empty, and    <strong>false</strong> otherwise.</p>    <hr>    <h2><a name="pop">pop</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  void pop();</pre>        </td>      </tr>    </table>    <p>The function pop() removes the top element of the current stack.</p>    <i>Related topics:</i><br>    <strong><a href="#top">top()</a>,</strong>     <hr>    <h2><a name="push">push</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  void push( const <a href="containers.html">TYPE</a> &amp;val );</pre>        </td>      </tr>    </table>    <p>The function push() adds <i>val</i> to the top of the current stack. For example:</p><pre>    stack&lt;int&gt; s;    for( int i=0; i &lt; 10; i++ )      s.push(i);    </pre>    <hr>    <h2><a name="size">size</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  size_type size();</pre>        </td>      </tr>    </table>    <p>The size() function returns the number of elements in the current stack. For example:</p><pre>    stack&lt;int&gt; s;    for( int i=0; i &lt; 10; i++ )      s.push(i);    cout &lt;&lt; "This stack has a size of " &lt;&lt; s.size() &lt;&lt; endl;        </pre>    <hr>    <h2><a name="top">top</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>   <a href="containers.html">TYPE</a> &amp;top();</pre>        </td>      </tr>    </table>    <p>The function top() returns a reference to the top element of the stack. For example, the following    code displays and empties a stack.</p><pre>    while( !s.empty() ) {      cout &lt;&lt; s.top() &lt;&lt; " ";      s.pop();    }</pre>    <i>Related topics:</i><br>    <strong><a href="#pop">pop()</a>,</strong>  </body></html>

⌨️ 快捷键说明

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