0

can any one explain y we use >>,<< operators in cpp

17th Aug 2016, 5:30 PM
vamshi
vamshi - avatar
2 ответов
+ 5
Those belong to cin and cout. (Part of their syntax.) cin>> is for getting input, and cout<< is for printing output.
17th Aug 2016, 6:02 PM
Alireza M
Alireza M - avatar
+ 3
@Ali Reza M: That is not true in general. Operators as "<<" and ">>" mean different things in different contexts. The operators "<<" and ">>" add to ostreams and istreams, correct, but for that to happen there has to be an ostream or istream. If you use the operators "<<" and ">>" with integers they shift bits. Same applies to other operators, too. Take "-", for example. In front of a number variable it toggles the sign. Between two numbers it subtracts. It's all about the context as many operators in C++ can be overloaded for custom types.
17th Aug 2016, 10:42 PM
Stefan
Stefan - avatar