0

Why would you need to use multiple "<<" in one cout line?

Ex: cout <<This <<is<<awesome!; When you can just use: cout<< "This is awesome!";

24th Dec 2015, 8:45 PM
Jason Elkins
Jason Elkins - avatar
4 Answers
+ 2
First This is not a good example altough multiple << can be used in case of varialbes and this is known as cascafind.As c++ accept only one variable at a time so cascading can be used Ex: cout << num1 << num2; insted of cout << num1; cout << num2;
11th Jun 2016, 6:13 PM
VARUN KUMAR
VARUN KUMAR - avatar
+ 1
If you wanted to insert a variable it would save you from having to type more lines of code. The all-text example is not a very good one.
11th Feb 2016, 2:50 PM
Mike
0
The frequent use of << operator is called cascading, this is beneficial in the case when we have to give a value of a variable. example cout <<"sum="<<add<<"product="<<pro; where add and pro are predefined local variables of the programme.
17th Jun 2016, 3:36 AM
Aman Ranjan Verma
Aman Ranjan Verma - avatar
0
my english not well, but i will try to let you understand. not must, just you can do that becuz the operation '<<' return cout I mean (cout << something) equal to (cout). so the cout can be used with many very interesting ways.
25th Jun 2016, 8:22 PM
xenon