How does while (std::cin >> value) work?

前端 未结 3 1307
逝去的感伤
逝去的感伤 2021-01-18 05:29

In an example given in C++ Primer,

#include 
using namespace std;

int main() {
    int sum = 0, value = 0;  
    while (std::cin >> va         


        
3条回答
  •  不要未来只要你来
    2021-01-18 06:12

    The overloaded operator>> function returns a reference to the stream itself, and the stream have an overloaded operator that allows it to be used in a boolean condition to see if the last operation went okay or not. Part of the "okay or not" includes end of file reached, or other errors.

提交回复
热议问题