重複の可能性:
C++ の条件文または制御文での変数の宣言と初期化
これの代わりに...
int value = get_value();
if ( value > 100 )
{
// Do something with value.
}
...値の範囲を必要な場所だけに減らすことは可能ですか:
if ( int value = get_value() > 100 )
{
// Obviously this doesn't work. get_value() > 100 returns true,
// which is implicitly converted to 1 and assigned to value.
}