Field wrote:
Hi,
the following snippet shows once executed this output:
2
2
I'd have rather expected this output:
2
10
Does anyone know why?
I don't believe the problem is related to converting an int to a string. It
seems to be related to the state of stringstream after the first input and
output. I'm not sure exactly what state it's put into, but if the state is
reset, the second sequence of calls will work as expected. I'll play
around a bit more to see if I can't find a way to determine the exact state
the stringstream is in after the first sequence of calls.
--
If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true.-Bertrand Russell