Skip to content

Latest commit

 

History

History
40 lines (32 loc) · 487 Bytes

File metadata and controls

40 lines (32 loc) · 487 Bytes

a

//缺少花括号界定块
if (ival1 != ival2){
	ival1 = ival2;
} else {
	ival1 = ival2 = 0;
}

b

//缺少花括号,默认occurs=1在块外执行
if (ival < minval){
    minval = ival;
    occurs = 1;
}

c

//错误,在块外使用ival
int ival = get_value();
if (ival)
    cout << "ival = " << ival << endl;
if (!ival)
    cout << "ival = 0\n";

d

//应使用相等而不是赋值
if (ival == 0)
    ival = get_value();