For an input stream to enter the EOF state, you should try to read the end of the stream end. That is, it is not enough to get to the end of the stream in the stream, you really need to try to read the character after the end. This attempt will activate the EOF state, which in turn will make cin.eof() return true.
However, in your case, you not only do not do this, you (most likely) have not even reached the end of the stream. If you type your 10 from the keyboard, you probably finished typing by pressing the [Enter] key. This led to the addition of a newline character to the input stream. So, what you are actually parsing with the >> operator in this case is actually a 10\n sequence. Since you requested the int value from the stream, it reads only numeric characters from the stream, that is, it reads 1 and 0 , but stops at \n . This \n stays in the stream. You never read it. Thus, it is obvious that your code never reaches the end-of-file position in the stream. You should think that cin.eof() will become true in this case.
AnT
source share