Can I use the following to check for end of input?
1 2 3
// rest of code
Yes. It's not about what "cin returns", it about what it can become.
What happens in your while() is this:
1) The first operator>> extracts num1 from cin and returns (the modified) cin. 2) The second operator>> extracts num2 from cin and returns the (again modified) cin. 3)cin is converted to void* which gets converted to bool.
If there was an error or end-of-file was reached, cin will basically be converted to false, otherwise it will be true.