0
can any one explain y we use >>,<< operators in cpp
2 ответов
+ 5
Those belong to cin and cout. (Part of their syntax.)
cin>> is for getting input, and cout<< is for printing output.
+ 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.