If the line is "show 0", then the first if statement will run and fail.
Code:
if(iss >> poly >> colon)
poly is an int, but "show" is not, so this causes a failed read. I think you are assuming that it will move on to the next if and try again, right? Unfortunately, when one failure happens it sets a failbit in the stream. you have to clear that failbit before trying again. You can do this by calling clear.
However, you stil might have a problem between the first and second if. Both start with an int, so if the line is meant for the second if, the first if might still read part of the data.
What I would do is re-set the istringstream after each if:
Code:
iss.clear();
iss.str(theTerms);