关于 std::endl

Code from reference

// endl example
#include <iostream>     // std::cout, std::end

int main () {

  int a=100;
  double b=3.14;

  std::cout << a;
  std::cout << std::endl;              // manipulator inserted alone
  std::cout << b << std::endl << a*b;  // manipulator in concatenated insertion
  std::endl (std::cout);               // endl called as a regular function

  return 0;
}

endl 是个函数…

ostream& endl (ostream& os);

cout重载了

ostream& ostream::operator<< (ostream& (*pf)(ostream&));

所以才有了

std::endl (std::cout);

的用法。