I've been learning C++ for about a month now, and as I've written programs I've noticed that enabling the user to cancel their input (during a cin loop) is a pain. For example, a program that takes user input and stores it in a vector would have a cin loop like this.
vector<int>reftest;
int number;
cout << "Input numbers for your vector.\n";
while(cin >> number)
reftest.push_back(number);
The ideal would be for the user to simply press enter, and for the program to exit the loop, but since whitespace isn't read I'm not sure how this would be handled. Instead, something ugly usually ends up being the case like telling the user to input a certain character to cancel their input.
Are there any certain methods that any of you use to handle user input?