You can also check the input string for a decimal as well. The check should occur after the stream is assigned to the variable 'a' so that you can verify that it is in fact a number.
1 2 3 4 5 6 7 8
int a;
std::string line;
std::getline(std::cin,line);
std::stringstream stream(line);
if ( !(stream >> a) || line.find('.')!=std::string::npos )
{
// Not an integer
}