If you are inputting through cin, then you can do this as you read in the input. You can add more and more checks to it to be more and more strict, but the basic premise is:
Code:
int value = 0;
while (!(cin >> value))
{
cin.clear();
cin.ignore(1000, '\n');
cout << "Invalid input, try again: ";
}
That works because cin >> evaluates to false if the read failed (like if you are expecting an int and the user types a char). It then enters the while loop where the cin stream is cleared of the error and the bad input is ignored.
You could also make an isInteger method that takes a string and does the same thing with a stringstream, but that probably is overkill for a school assignment.