I'm going through the full tutorial at cplusplus.com, coding and compiling each example manually. Regularly, I stumble upon something that leaves me perplexed.
I am currently learning this section: http://www.cplusplus.com/doc/tutorial/structures/ . There are some subtleties that could easily be overlooked by only reading the tutorial. The advantage of typing everything by hand is that such details do stand out.
In the above page, there are two sample programs. One has this line:
stringstream(mystr) >> yours.year;
The other one has this line:
(stringstream) mystr >> pmovie->year;
What I don't understand is the difference (if any) between type (myVar) = x;
and (type) myVar = x;
.
I am not doing the whole tutorial in sequential order. I checked but didn't find this addressed anywhere, though I may have missed it.
- Is there a difference?
- Is there a preferred way to do it one way rather than the other?