+ 1

Is std::cout a function?

If so, then what does "<<" mean and does it have any uses in other connotations?

23rd May 2018, 8:23 PM
Zuke
Zuke - avatar
3 Respostas
+ 1
cout is an object of std class. It is a console output which, suprisingly, spit things out to console. << is overloaded for cout purpose to "put" a string of bits into the console output. << can also be used as a bit shift operator, in that case, left shift. for example: a = 1; a = a << 1; // shifting a by two bits to the left a bits are shifted to the left with result of a holding a value of 2
23rd May 2018, 8:31 PM
Paul
+ 1
Shift operators are often used with microcontrollers to set a given bit to a value, for example in Atmega8 to enable a timer. It is done by sending a byte of data like 00001000, so the 4th bit will be enabled. It looks somewhat like this: TCCR0 I = 1 << 3; where | is a bitwise OR
23rd May 2018, 8:34 PM
Paul
+ 1
Thanks
24th May 2018, 5:53 AM
Zuke
Zuke - avatar