Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does istream::operator>>( const char& ) as no such function is implemented?

Looking at istream documentation, you will see that there is no implementation of function istream &operator>>( char& ), but if you compile and run the code below, it will work just as expected.

#include<iostream>

int main( ) {

  char c;

  std::cin >> c;

  std::cout << c << std::endl;

  return( 0 );

}

Given cin is an object for class istream, which specialization of operator>> is called when std::cin >> c; is executed?

like image 294
user1574855 Avatar asked Mar 13 '26 20:03

user1574855


1 Answers

operator>> also is implemented as non-member functions.

istream& operator>> (istream& is, char& c)

like image 181
Jesse Good Avatar answered Mar 16 '26 10:03

Jesse Good



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!