为什么布尔值&&
在这种情况下起作用?当我输入“黄色”时,它不应该“短路”并且不检查第二个条件,因为第一个条件“红色”是错误的?
#include <iostream>
#include <string>
using namespace std;
int main()
{
string color;
do
{
cout << "Pick one of the colors: red, yellow, or blue\n";
cin >> color;
}while ((color != "red") && ( color != "yellow") && ( color != "blue"));
{
cout << "I like that color too";
return 0;
}
}