I am wondering if someone could write a very simple example of an entry validation function. I am trying to understand how to do it, but I am working with a currently limited understanding. I know you are supposed to read cin as a string. From there I want to check to see if the entry is zero, positive, negative, a whole number, a decimal, or none of these. The code I have pasted shows the kind of things I have been experimenting with, though I am not feeling too confident using these things since I haven't been able to figure this out. I realize that beginner's code might not actually be the best way to do things, but what I really want is just somewhere to start where I can begin to understand what is happening.
static_cast<double>(stream.peek()) != std::char_traits <double>::eof()
Why? The character representation has no relation to the type of data you're attempting to extract. Also, this looks like it would fail on entry of a value followed solely by whitespace which is not typically preferred behavior, although I concede it may be preferred by the OP.
thanks again cire. your suggestion is undoubtedly more elegant and robust. i've updated my file with current post's link as this question pops up every now and then and will start spreading the message from now on