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

📄 all.html

📁 从www.CppReference.com打包的C++参考手册
💻 HTML
📖 第 1 页 / 共 4 页
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>  <meta name="generator" content=  "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org">  <title>C/C++ Keywords</title>  <link href="../cppreference.css" rel="stylesheet" type="text/css"></head><body><table>  <tr>  <td>  <div class="body-content">  <div class="header-box">    <a href="../index.html">cppreference.com</a> &gt; <a href=    "index.html">C/C++ Keywords</a>  </div><hr>  <div class="name-format">    asm  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  asm( &quot;instruction&quot; );</pre>  <p>The asm command allows you to insert assembly language commands  directly into your code. Various different compilers allow differing  forms for this command, such as</p>  <pre class="example-code">   asm {     instruction-sequence   }            </pre>  <p>or</p>  <pre class="example-code">   asm( instruction );          </pre>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    auto  </div>  <p>The keyword auto is used to declare local variables, and is purely  optional.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="register.html">register</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    bool  </div>  <p>The keyword bool is used to declare Boolean logic variables; that  is, variables which can be either true or false.</p>  <p>For example, the following code declares a boolean variable called  <em>done</em>, initializes it to false, and then loops until that  variable is set to true.</p>  <pre class="example-code">   bool done = false;   while( !done ) {   ...   }            </pre>  <p>Also see the <a href="../data_types.html">data types</a> page.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="char.html">char</a><br>    <a href="double.html">double</a><br>    <a href="false.html">false</a><br>    <a href="float.html">float</a><br>    <a href="int.html">int</a><br>    <a href="long.html">long</a><br>    <a href="short.html">short</a><br>    <a href="signed.html">signed</a><br>    <a href="true.html">true</a><br>    <a href="unsigned.html">unsigned</a><br>    <a href="wchar_t.html">wchar_t</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    break  </div>  <p>The break keyword is used to break out of a <a href=  "do.html">do</a>, <a href="for.html">for</a>, or <a href=  "while.html">while</a> loop. It is also used to finish each clause of  a <a href="switch.html">switch</a> statement, keeping the program  from &quot;falling through&quot; to the next case in the code. An  example:</p>  <pre class="example-code">   while( x &lt; 100 ) {     if( x &lt; 0 )       break;     cout &lt;&lt; x &lt;&lt; endl;     x++;   }            </pre>  <p>A given break statement will break out of only the closest loop,  no further. If you have a triply-nested for loop, for example, you  might want to include extra logic or a <a href="goto.html">goto</a>  statement to break out of the loop.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="continue.html">continue</a><br>    <a href="do.html">do</a><br>    <a href="for.html">for</a><br>    <a href="goto.html">goto</a><br>    <a href="switch.html">switch</a><br>    <a href="while.html">while</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    case  </div>  <p>The case keyword is used to test a variable against a certain  value in a <a href="switch.html">switch</a> statement.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="default.html">default</a><br>    <a href="switch.html">switch</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    catch  </div>  <p>The catch statement handles exceptions generated by the <a href=  "throw.html">throw</a> statement.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="throw.html">throw</a><br>    <a href="try.html">try</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    char  </div>  <p>The char keyword is used to declare character variables. For more  information about variable types, see the <a href=  "../data_types.html">data types</a> page.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="bool.html">bool</a><br>    <a href="double.html">double</a><br>    <a href="float.html">float</a><br>    <a href="int.html">int</a><br>    <a href="long.html">long</a><br>    <a href="short.html">short</a><br>    <a href="signed.html">signed</a><br>    <a href="unsigned.html">unsigned</a><br>    <a href="void.html">void</a><br>    <a href="wchar_t.html">wchar_t</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    class  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  class class-name : inheritance-list {  private-members-list;      protected:  protected-members-list;  public:  public-members-list;  } object-list;</pre>  <p>The class keyword allows you to create new classes.  <em>class-name</em> is the name of the class that you wish to create,  and <em>inheritance-list</em> is an optional list of classes  inherited by the new class. Members of the class are private by  default, unless listed under either the protected or public labels.  <em>object-list</em> can be used to immediately instantiate one or  more instances of the class, and is also optional. For example:</p>  <pre class="example-code">   class Date {     int Day;     int Month;     int Year;   public:     void display();   };           </pre>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="friend.html">friend</a><br>    <a href="private.html">private</a><br>    <a href="protected.html">protected</a><br>    <a href="public.html">public</a><br>    <a href="struct.html">struct</a><br>    <a href="this.html">this</a><br>    <a href="typename.html">typename</a><br>    <a href="union.html">union</a><br>    <a href="virtual.html">virtual</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    const  </div>  <p>The const keyword can be used to tell the compiler that a certain  variable should not be modified once it has been initialized.</p>  <p>It can also be used to declare functions of a class that do not  alter any class data.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="const_cast.html">const_cast</a><br>    <a href="mutable.html">mutable</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    const_cast  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  const_cast&lt;type&gt; (object);</pre>  <p>The const_cast keyword can be used to remove the  <strong>const</strong> or <strong>volatile</strong> property from  some variable.  The target data type must be the same as the source  type, except (of course) that the target type doesn&#39;t have to be  <a href="const.html">const</a>.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="const.html">const</a><br>    <a href="dynamic_cast.html">dynamic_cast</a><br>    <a href="reinterpret_cast.html">reinterpret_cast</a><br>    <a href="static_cast.html">static_cast</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    continue  </div>  <p>The continue statement can be used to bypass iterations of a given  loop.</p>  <p>For example, the following code will display all of the numbers  between 0 and 20 except 10:</p>  <pre class="example-code">   for( int i = 0; i &lt; 21; i++ ) {     if( i == 10 ) {       continue;     }     cout &lt;&lt; i &lt;&lt; &quot; &quot;;   }            </pre>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="break.html">break</a><br>    <a href="do.html">do</a><br>    <a href="for.html">for</a><br>    <a href="while.html">while</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    default  </div>  <p>A default <a href="case.html">case</a> in the <a href=  "switch.html">switch</a> statement.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="case.html">case</a><br>    <a href="switch.html">switch</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    delete  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  delete p;  delete[] pArray;</pre>  <p>The delete operator frees the memory pointed to by <em>p</em>. The  argument should have been previously allocated by a call to <a href=  "new.html">new</a>. The second form of delete should be used to  delete an array.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    (Standard C Memory) <a href="../stdmem/free.html">free</a><br>    (Standard C Memory) <a href="../stdmem/malloc.html">malloc</a><br>    <a href="new.html">new</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    do  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  do {  statement-list;  } while( condition );</pre>  <p>The do construct evaluates the given <em>statement-list</em>  repeatedly, until <em>condition</em> becomes false. Note that every  do loop will evaluate its statement list at least once, because the  terminating condition is tested at the end of the loop.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="break.html">break</a><br>    <a href="continue.html">continue</a><br>    <a href="for.html">for</a><br>    <a href="while.html">while</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    double  </div>  <p>The double keyword is used to declare double precision  floating-point variables. Also see the <a href=  "../data_types.html">data types</a> page.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="bool.html">bool</a><br>    <a href="char.html">char</a><br>    <a href="float.html">float</a><br>    <a href="int.html">int</a><br>    <a href="long.html">long</a><br>    <a href="short.html">short</a><br>    <a href="signed.html">signed</a><br>    <a href="unsigned.html">unsigned</a><br>    <a href="void.html">void</a><br>    <a href="wchar_t.html">wchar_t</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    dynamic_cast  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  dynamic_cast&lt;type&gt; (object);</pre>  <p>The dynamic_cast keyword casts a datum from one type to another,  performing a runtime check to ensure the validity of the cast. If you  attempt to cast between incompatible types, the result of the cast  will be <strong>NULL</strong>.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="const_cast.html">const_cast</a><br>    <a href="reinterpret_cast.html">reinterpret_cast</a><br>    <a href="static_cast.html">static_cast</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    else  </div>  <p>The else keyword is used as an alternative case for the <a href=  "if.html">if</a> statement.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="if.html">if</a>  </div>  </div>  </td>  

⌨️ 快捷键说明

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