Huh? I don't see why you would do this other then maybe to handle user error when they enter a letter instead of a number but that can be handled in much better ways I would believe.
I would tell the professor your shouldn't do it. It is just a unneeded step and there are better way to handle stream errors when the user enters a char instead of a number for a int variable.
Here is a example of how you can safeguard a stream from going into error if the user doesn't enter a number into a int.
#include <iostream>
#include <string>
#include <limits>
usingnamespace std;
int main ()
{
int number;
cout << "Please enter a number: ";
cin >> number;
// Will run so long as the steam is in error like when
// the user enters a character instead of a number or a string instead
// of a number
while (cin.fail())
{
cout << "Error! You most likely didn't enter a number!" << endl;
cout << "Please try again" << endl;
// Fixes the error and then clears the error state of the stream.
cin.ignore(numeric_limits<std::streamsize>::max(), '\n');
cin.clear();
cout << "Please enter a number: ";
cin >> number;
}
return 0;
}