You need to check the return value of the stream when it tries to convert to the number. You can do this with the stringstream or directly with cin. For example, to do it with cin you could do:
Code:
while (!(cin >> number))
{
cin.clear(); // clear failbit from character
cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); // ignore bad input
cout<<"U've entered not an integer!!"<<endl;
}
You should #include <limits> and #include <ios> for the stuff in the ignore line, or you can just use cin.ignore(1000, '\n');.
If you wanted to use the stringstream version, you would do basically the same thing. Check the state of the stream after it tries to convert to an int.