이 코드는 "여기서 뭔가"를 인쇄해야하지만 실제로 잘못는
void test(){
string str = "";
int count = 0;
if (count > str.length() - 1){
cout << "something here" << endl;
return;
}
cout << "wrong" << endl;
}
를 인쇄하지만, 나는 다음과 같이 약간 변경하면, 여기 "뭔가를 인쇄합니다 "
void test_2(){
string str = "";
int count = 0;
int last_index = str.length() - 1;
if (count > last_index){ // change to last_index
cout << "something here" << endl;
return;
}
cout << "wrong" << endl;
}
누구나 나를 도와 줄 수 있습니까?
컴파일러 경고를 켜거나 켭니다. – chris