+ 2
Instead of using multiple insertion operators,we can use only one operator right??? It will minimise the code right????
7 ответов
+ 3
"Instead of using multiple insertion operators,we can use only one operator right???"
One << operator for every commit to the output stream. But if you are talking about the "cout" global object (as your question tag refers to), it's a matter of style and good practices. For example, it's best to associate all related pieces of the output to one cout as
int x = 20;
cout << "Who knows what's going to happen to programming world "
<< x << " years from now. But, almost all analysts have reached "
<< "to a general consensus on the matter of improved productivity."
<< endl;
Or
cout << "Who knows what's going to happen to programming world "
"20 years from now. But, almost all analysts have reached "
"to a general consensus on the matter of improved productivity.\n";
Versus, the unrelated facts and data as
cout << "function 1's return value is : " << f1() << endl;
cout << "function 2's return value is : " << f2() << endl;
0
Make sense. But i don't think it will make the code easier.
0
You are talking about C++?
0
I’m new to C, but this allows you to insert variables into your text stream
0
yes
0
cout<<"Hello"
0
return (0)