Click here to Skip to main content
15,912,507 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi i am learning c++
why we use << and >> in cin and cout Instead of parentheses ?
Posted
Comments
CPallini 19-Jun-11 8:03am    
They reasonably show the flow direction of the stream. Why do you think parentheses are more appropriate?
Sergey Alexandrovich Kryukov 19-Jun-11 23:07pm    
That reply would be quite enough, why saying anything else?
--SA

These are overloaded operators. In a mathematical or logical expression these are the logical shift operators, as shown here[^]. However in a C++ class these operators can be overloaded to provide some other functionality, and in streams they are used as insertion and extraction operators as described here[^] and here[^].
 
Share this answer
 
In addition to the other solutions, using the insertion and extraction operators is just convenience. I guess Stroustrup[^] just found it to be more readable and easier to write:
C++
cout << "The value is: " << value << endl;

instead of (hypothetical):
C++
cout.write("The value is: ").writeln(value).flush();

which could have been an alternative.
 
Share this answer
 
if u want to accept data in to a variable

cin>>a means accepting data which we entered into variable 'a'

cout<<a means ur trying to display the value present in variable 'a'
 
Share this answer
 
Comments
Richard MacCutchan 19-Jun-11 7:48am    
u ur
Please don't use txtspk as it makes you appear unprofessional, and also means nothing to people who do not have a good command of English.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900