title: Why do I need to clear a stringstream variable with each iteration of a loop in which it is used
body: <p>At my school we have to follow a style guide which states we must declare each variable at the top of the function where it is used, as opposed to right before it is used. This often means you have to reset or clear variables while using them inside loops since they are not declared inside that loop. I don't understand why a stringstream variable needs to be "clear"ed with each loop iteration and was hoping someone could shed light on this. I know <em>how</em> to clear it just want to know <em>why</em> it's necessary.  </p>