A istringstream allows input to be read in from a string, in the same way as from cin or from a file.
These two lines do most of the work (though the preceding lines set everything up)
1 2
while(x >> temp)
accumulator += temp;
Here it is reading a number from the stringstream x into the variable temp
then temp is added to the accumulator. The while loop ends when there are no more numbers in the stringstream.