can any one explain y we use >>,<< operators in cpp | SoloLearn: Learn to code for FREE!

0

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

c++

8/17/2016 5:30:17 PM

vamshi

2 Answers

New Answer

+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.