Hi,
I have a question about the line marked with a comment in the code below.
why did author use stringstream() instead of cin ?
source: tutorial-->data structures
The method used consumes the entire line that the user enters, including anything after the year and the newline character. In other words, the user could enter
2014 and here is some junk
and it would work. If you used cin >> films[n].year then it would consume only the year and not the trailing junk or the newline.
By the way the construct is interesting. It creates an anonymous temporary stringstream. In other words line 24 is like doing this: