是否有可能在while语句中有三个条件?
例如:
cout << "\n\nHow would you like your parcel shipped?\n (please type standard, express"
" or same day)" << endl;
cin >> method;
while (method != ("standard" && "express" && "same day"))
{
cout << "invalid input: please follow the instructions carefully.." << endl;
cout << "\n\nHow would you like your parcel shipped?\n (please type 'standard',"
" 'express' or 'same day')" << endl;
cin >> method;
}
Run Code Online (Sandbox Code Playgroud)
我问的原因是当我运行这段代码时,它会进入一个无限循环,我无法理解为什么.
while (method != "standard" && method != "express" && method != "same day")
Run Code Online (Sandbox Code Playgroud)