@leon4393 You may wonder why you need to use the form which dutch shows. When you basically understand how templates work, I suggest reading the basics about STL containers:
The form used in @leon4393's post is like that in Stroustrup's "home made" include covered in his book "Principles and Practice", but of course such a call requires that header, which he advocates.
I think new students may tend to forget it comes from that header.
Note that different compilation systems and programmer communities have different conventions for where to put header files. The book assumes that a header file is in the same directory/folder as the .cpp files and uses "plain" #include "std_lib_facilities.h" . If that doesn't work, try #include "../std_lib_facilities.h" (one level up) and #include "../../std_lib_facilities.h" (two levels up).
So operator>> (istream&, something_else) typically returns the passed-in istream to allow operator chaining. You probably knew that.
However! istreams implement operatorbool as of C++11, which lets them be used in boolean contexts. In this case, it's effectively the same as using !(cin >> temp).fail().
More info: https://en.cppreference.com/w/cpp/io/basic_ios/operator_bool
With cpp.sh you can select "Text" for standard input and type a few lines in the text box, which will act like an input file, complete with eof signal.