Are cin and cout allowed to be used even as right hand operands? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Are cin and cout allowed to be used even as right hand operands?

In C ++, is it possible to swap the positions of the two operands of an input/output statement with simultaneously switching the redirection operator, in a similar way to what occurs in mathematics as regards the inequalities? Practically, I wonder for instance if writing "Hello, world!" >> cout; could be considered as correct and valid as writing cout << "Hello, world!"; .

17th Nov 2016, 3:15 PM
Criso Prasio
Criso Prasio - avatar
2 Answers
+ 2
No, unless you find and use a compiler that evaluates it from the right to the left instead of left to right.
17th Nov 2016, 3:17 PM
Ben
Ben - avatar
+ 1
Interesting idea:))) I am affraid, there is not so simple. Look chapter "Operator Overloading" here in C++ course. Maybe you shall find to way how to recode for your class.. :))
17th Nov 2016, 4:45 PM
Petr Hatina
Petr Hatina - avatar