The problem is that this line:
ss >> hour;
sets the eof bit of your stream because you reached the end of the string. When the eof bit is set, then the stream does not work any more. So you have to clear it after setting the empty string:
ss.str(string())
ss.clear()