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

📄 keywords_details.html

📁 ssd5 数据结构的课件
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<!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/C++ Keywords</title>  </head>  <body bgcolor="#ffffff">    <table width="100%" bgcolor="#eeeeff">      <tr>        <td><a href="index.html">cppreference.com</a> -&gt; <a href="keywords.html">C/C++ Keywords</a> -&gt;        Details</td>      </tr>    </table>    <h1>C/C++ Keywords</h1>    <hr>    <h2><a name="asm">asm</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  asm( "instruction" );</pre>        </td>      </tr>    </table>    <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>    asm {      instruction-sequence    }</pre>    <p>or</p><pre>    asm( instruction );    </pre>    <hr>    <h2><a name="auto">auto</a></h2>    <p>The keyword auto is used to declare local variables, and is purely optional.</p>    <hr>    <h2><a name="bool">bool</a></h2>    <p>The keyword bool is used to declare Boolean logic variables; that is, variables which can be either    true or false. An example:</p><pre>    bool done = false;    while( !done ) {    ...    }    </pre>    <p>Also see the <a href="data_types.html">data types</a> page.</p>    <hr>    <h2><a name="break">break</a></h2>    <p>The break keyword is used to break out of a <a href="#do">do</a>, <a href="#for">for</a>, or <a href=    "#while">while</a> loop. It is also used to finish each clause of a <a href="#switch">switch</a>    statement, keeping the program from "falling through" to the next case in the code. An example:</p><pre>    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">goto</a>    statement to break out of the loop.</p>    <hr>    <h2><a name="case">case</a></h2>    <p>A single test in the <a href="#switch">switch</a> statement.</p>    <i>Related topics:</i><br>    <strong><a href="#default">default</a>, <a href="#switch">switch</a></strong>     <hr>    <h2><a name="catch">catch</a></h2>    <p>The catch statement handles exceptions generated by the <a href="#throw">throw</a> statement.</p>    <i>Related topics:</i><br>    <strong><a href="#throw">throw</a>, <a href="#try">try</a></strong>     <hr>    <h2><a name="char">char</a></h2>    <p>The char keyword is used to declare character variables. Also see the <a href="data_types.html">data    types</a> page.</p>    <hr>    <h2><a name="class">class</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  class class-name : inheritance-list {    private-members-list;        protected:      protected-members-list;    public:      public-members-list;  } object-list;</pre>        </td>      </tr>    </table>    <p>The class keyword allows you to create new classes. <i>class-name</i> is the name of the class that    you wish to create, and <i>inheritance-list</i> is an optional list of classes inherited by the new    class. Members of the class are <strong>private</strong> by default, unless listed under either the    <strong>protected</strong> or <strong>public</strong> labels. <i>object-list</i> can be used to    immediately instantiate one or more instances of the class, and is also optional. For example:</p><pre>    class Date {      int Day;      int Month;      int Year;    public:      void display();    };</pre>    <i>Related topics:</i><br>    <strong><a href="#struct">struct</a>, <a href="#union">union</a></strong>     <hr>    <h2><a name="const">const</a></h2>    <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>    <i>Related topics:</i><br>    <strong><a href="#const_cast">const_cast</a></strong>     <hr>    <h2><a name="const_cast">const_cast</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  const_cast&lt;type&gt; (object);</pre>        </td>      </tr>    </table>    <p>The const_cast keyword can be used to remove the "const-ness" of some datum. The target data type must    be the same as the source type, except (of course) that the target type doesn't have to be    <strong>const</strong>.</p>    <i>Related topics:</i><br>    <strong><a href="#dynamic_cast">dynamic_cast</a>, <a href="#reinterpret_cast">reinterpret_cast</a>, <a    href="#static_cast">static_cast</a></strong>     <hr>    <h2><a name="continue">continue</a></h2>    <p>The continue statement can be used to bypass iterations of a given loop. For example, the following    code will display all of the numbers between 0 and 20 except 10:</p><pre>    for( int i = 0; i &lt; 21; i++ ) {      if( i == 10 ) {        continue;      }      cout &lt;&lt; i &lt;&lt; " ";    }</pre>    <i>Related topics:</i><br>    <strong><a href="#break">break</a>, <a href="#do">do</a>, <a href="#for">for</a>, <a href=    "#while">while</a></strong>     <hr>    <h2><a name="default">default</a></h2>    <p>A default case in the <a href="#switch">switch</a> statement.</p>    <i>Related topics:</i><br>    <strong><a href="#case">case</a>, <a href="#switch">switch</a></strong>     <hr>    <h2><a name="delete">delete</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  delete p;  delete[] pArray;</pre>        </td>      </tr>    </table>    <p>The delete operator frees the memory pointed to by <i>p</i>. The argument should have been previously    allocated by a call to <a href="#new">new</a>. The second form of delete should be used to delete an    array.</p>    <i>Related topics:</i><br>    <strong><a href="#new">new</a></strong>     <hr>    <h2><a name="do">do</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  do {    statement-list;  } while( condition );</pre>        </td>      </tr>    </table>    <p>The do construct evaluates the given <i>statement-list</i> repeatedly, until <i>condition</i> 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>    <i>Related topics:</i><br>    <strong><a href="#for">for</a>, <a href="#while">while</a></strong>     <hr>    <h2><a name="double">double</a></h2>    <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>    <hr>    <h2><a name="dynamic_cast">dynamic_cast</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  dynamic_cast&lt;type&gt; (object);</pre>        </td>      </tr>    </table>    <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>    <i>Related topics:</i><br>    <strong><a href="#const_cast">const_cast</a>, <a href="#reinterpret_cast">reinterpret_cast</a>, <a href=    "#static_cast">static_cast</a></strong>     <hr>    <h2><a name="else">else</a></h2>    <p>The else keyword is used as an alternative case for the <a href="#if">if</a> statement.</p>    <hr>    <h2><a name="enum">enum</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  enum name {name-list} var-list;</pre>        </td>      </tr>    </table>    <p>The enum keyword is used to create an enumerated type named <i>name</i> that consists of the elements    in <i>name-list</i>. The <i>var-list</i> argument is optional. For example:</p><pre>    enum color {red, orange, yellow, green, blue, indigo, violet};    color c1 = indigo;    if( c1 == indigo ) {      cout &lt;&lt; "c1 is indigo" &lt;&lt; endl;    }</pre>    <hr>    <h2><a name="explicit">explicit</a></h2>    <p>When a constructor is specified as explicit, no automatic conversion will be used with that    constructor --it will only be used when an initialization exactly matches a call to that constructor.</p>    <hr>    <h2><a name="extern">extern</a></h2>    <p>The extern keyword is used to inform the compiler about variables declared outside of the current    scope. Variables described by extern statements will not have any space allocated for them, as they    should be properly defined elsewhere.</p>    <p>Extern statements are frequently used to allow data to span the scope of multiple files.</p>    <hr>    <h2><a name="false">false</a></h2>    <p>The Boolean value of "false".</p>    <i>Related topics:</i><br>    <strong><a href="#bool">bool</a>, <a href="#true">true</a></strong>     <hr>    <h2><a name="float">float</a></h2>    <p>The float keyword is used to declare floating-point variables. Also see the <a href=    "data_types.html">data types</a> page.</p>    <hr>    <h2><a name="for">for</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  for( initialization; test-condition; increment ) {    statement-list;  }</pre>        </td>      </tr>    </table>    <p>The for construct is a general looping mechanism consisting of 4 parts:</p>    <ol>      <li>the <i>initialization</i>, which consists of 0 or more comma-delimited variable initialization      statements</li>      <li>the <i>test-condition</i>, which is evaluated to determine if the execution of the for loop will      continue</li>      <li>the <i>increment</i>, which consists of 0 or more comma-delimited statements that increment      variables</li>      <li>and the <i>statement-list</i>, which consists of 0 or more statements that will be executed each      time the loop is executed.</li>    </ol>    For example: <br>    <br>     <pre>    for( int i = 0; i &lt; 10; i++ ) {      cout &lt;&lt; "i is " &lt;&lt; i &lt;&lt; endl;    }    int j, k;    for( j = 0, k = 10;         j &lt; k;         j++, k-- ) {      cout &lt;&lt; "j is " &lt;&lt; j &lt;&lt; " and k is " &lt;&lt; k &lt;&lt; endl;    }

⌨️ 快捷键说明

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