#includeusing namespace std; int main() { double taxes=0; //taxi char test; test=(cin>>taxes); cout< 错误的,因为cin作为一个对象是没有返回值的,有返回值的是<<>>,这个可以作为if条件的真值判断。
实例代码:
例1:
#includeusing namespace std; int main() { double a = 0; //taxi if ((cin >> a) == cin) { cout << "Equal" << endl; // Yes } else { cout << "Not Equal" << endl; } return 0; } 例2:
#includeusing namespace std; int main() { double taxes = 0; //taxi int test; while(cin >> taxes) { //test } cout << cin; return 0; }
结果,当是eof或者是错误输入的时候



