The parentheses are now around "stringstream," not around "mystr". I changed the code in the third example to put the parentheses around "mystr" instead, and it seemed to run fine. However, I'm quite new to c++ coding so I'm wondering, is there any functional difference (possibly behind the scenes) between putting the parentheses around "stringstream" and putting them around "mystr"?
One uses implicit casting, and one uses explicit object construction.
stringstream(mystr) explicitly calls the stringstream ctor which takes a string as a parameter. This is easier to visualize when a class takes multiple parameters... like say ExampleClass( foo, bar )
(stringstream)mystr does a C-style cast, which attempts to convert mystr to a stringstream object by searching for an appropriate stringstream ctor. This implicitly calls the constructor.
The end result in each case is the same. So functionally, they're equivilent. However the difference between the two is that stringstream(mystr) is more explicit. If stringstream's ctor were declared explicit, I think (stringstream)mystr would fail -- but that's not the case here.
EDIT:
I just tested and apparently even if the ctor is explicit it doesn't make any difference, so I guess maybe there is no difference at all. *shrug*