![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
cin.clear could definitely be necessary if the stream is in a fail state for any reason. It's not even uncommon. If input were directed, say, to an integer variable, and the user struck a key or key sequence that couldn't be properly converted, a failure condition would occur. When this happens, the stream will not function properly until the failure condition is cleared. This is a quite common topic in the C++ forum. Streams should always be checked after use to make sure that a failure has not occurred. Any thing less is amateurish, if one hasn't discovered the facts yet, or schlocky programming if one has, but chooses to ignore the possibility, anyway.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|