Which should I use? Is there a difference?

So far I've been using this:
1
2
std::cout << "This statement is becoming raaaaaaaaaaaaaaaaaaather long"
<<"so I'll split it into two by pressing enter";


but now I see that I can do this:
1
2
std::cout << "This statement is becoming raaaaaaaaaaaaaaaaaaather long"
"so I'll split it into two by pressing enter";


Without the second <<. Is it better to use a << every time you split an output statement over more lines?
Last edited on
closed account (zb0S216C)
In my opinion, it's down to your personal preference, if they are both valid, of course.
Last edited on
Both are legal syntax. It boils down to preference and code legibility. Choose which one works better for you in the long run.
The second one will call operator << once instead of twice. So it's better.
C++ gives you so maaaany choices. I'm not sure if that is good or bad yet. I'm also not sure which I want to use.. hmm. I think I'll keep using the << operator every time since that is what I've been doing and I don't think the extra calls will make that large of difference.
Topic archived. No new replies allowed.