Jan 23, 2011 at 2:59am UTC
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 Jan 23, 2011 at 3:00am UTC
Jan 23, 2011 at 3:37am UTC
In my opinion, it's down to your personal preference, if they are both valid, of course.
Last edited on Jan 23, 2011 at 3:37am UTC
Jan 23, 2011 at 3:39am UTC
Both are legal syntax. It boils down to preference and code legibility. Choose which one works better for you in the long run.
Jan 23, 2011 at 3:40am UTC
The second one will call operator << once instead of twice. So it's better.
Jan 23, 2011 at 3:48am UTC
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.