+ 3
>>OPERATORS <<
What is the purpose and use of >> << these operators in c++.
8 Respuestas
+ 7
AFAIK, Shift left (<<) is used to shift the bit to left and similarly shift right (>>) is used to shift the bit to right. let us see a example.
Consider 4<<1,
Here 4 will be considered in bits i.e(100) so <<1 means shift the bit to left once, that will be 1000 which is 8
So 4<<1 = 8.
I hope this helps.
+ 7
No Maksym. You're wrong. <<,>> are shift left and shift right operators and being overloaded to cout and cin respectively.
+ 2
@Maksym Zielinski
I know that.
But these are actually overloaded operator for the purpose you mentioned what is their use when they are not overloaded.
+ 2
@Mr Robot
Yes, That was what I searching for can you please explain their use.
+ 2
cout and cin are objects of iostream and the operators are overloaded for the input and output function. Pay attention to the "." in other cin and cout commands.
cin.getline()
cout.write()
cin.get()
+ 1
Without overloading they are just bitwise operators
0
>> when you put data into program
<< when you send data out of program
0
And what cout and cin basically means? :)