名前空間
変種
操作

「cpp/keyword/while」の版間の差分

提供: cppreference.com
< cpp‎ | keyword
(r2.7.3) (ロボットによる 追加: en, it, pl, tr)
(Translated from the English version using Google Translate)
1行: 1行:
{{title|while}}
+
{{
 +
title|while
 +
 +
 +
 +
}}
  
文法:
 
<syntaxhighlight lang="cpp">
 
    while( 条件 ) {
 
      命令リスト;
 
    }
 
</syntaxhighlight>
 
 
whileキーワードは、条件がtrueの間、命令リストが評価され続けるループ構文に使用されます。もしも、条件式が初めからfalseの場合は、命令リストは1回も実行されないことに注意してください。命令リストが最低一回は評価されることを保証した場合にはdoループを使用してください。サンプル:
 
<syntaxhighlight lang="cpp">
 
    bool done = false;
 
    while( !done ) {
 
      ProcessData();
 
      if( StopLooping() ) {
 
        done = true;
 
      }
 
    }
 
</syntaxhighlight>
 
 
関連トピック: [[cpp/keyword/break | break]], [[cpp/keyword/continue | continue]], [[cpp/keyword/do | do]], [[cpp/keyword/for | for]], [[cpp/keyword/if | if]]
 
 
[[en:cpp/keyword/while]]
 
 
[[it:cpp/keyword/while]]
 
[[it:cpp/keyword/while]]
 +
 
[[pl:cpp/keyword/while]]
 
[[pl:cpp/keyword/while]]
 
[[tr:cpp/keyword/while]]
 
[[tr:cpp/keyword/while]]

2012年10月26日 (金) 07:00時点における版

 
 
C++言語
一般的なトピック
フロー制御
条件付き実行文
繰り返し文 (ループ)
ジャンプ文
関数
関数宣言
ラムダ関数宣言
inline 指定子
例外指定 (C++20未満)
noexcept 指定子 (C++11)
例外
名前空間
指定子
decltype (C++11)
auto (C++11)
alignas (C++11)
記憶域期間指定子
初期化
代替表現
リテラル
ブーリアン - 整数 - 浮動小数点
文字 - 文字列 - nullptr (C++11)
ユーザ定義 (C++11)
ユーティリティ
属性 (C++11)
typedef 宣言
型エイリアス宣言 (C++11)
キャスト
暗黙の変換 - 明示的な変換
static_cast - dynamic_cast
const_cast - reinterpret_cast
メモリ確保
クラス
クラス固有の関数特性
特別なメンバ関数
テンプレート
その他
 
 

用法

  • NJループ:ループの宣言として
    Original:
    NJループ: as the declaration of the loop
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • NJループ:ループの終了条件の宣言として
    Original:
    NJループ: as the declaration of the terminating condition of the loop
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.