There are three standard streams: stdin, stdout, and stderr; for input, output, and errors respectively. In C++, they are accessed with cin, cout, and cerr.
The cin.clear(); has nothing to do with cerr. What it does is reset the input stream's status flags to "everything's ok" so that you can continue reading stuff from it. (As long as any of the badbit, failbit, or eofbit flags are set, you cannot read/write from a stream.)
[edit] cout is buffered, but cerr is not.
The code you posted clears the input stream, then reads the remainder of the bad input before returning.