开发者

c++ reading from cin

If I have:

double x;
cin >> x;

then I proceed to enter a character or开发者_如何学JAVA a string, what would happen? And what would the statement cin >> x return?


The istream::operator>> always returns an istream object, no matter what. The value of x however would be undefined, and the istream would be "errored" and wouldn't work again till you cleared the error state.

This is just from memory and I really haven't thought about this before, so if someone sees that this is wrong, I'll remove it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜