error C2143: 语法错误 : 缺少“;”(在“&”的前面)

报错:

  error C2143: 语法错误 : 缺少“;”(在“&”的前面)

代码:

#include <iostream>

ostream & << (ostream& os, int i)

{

  return os << i ;

}

解决方法:加入using namespace std;

解决报错后代码:

#include <iostream>

using namespace std;

ostream & << (ostream& os, int i)

{

  return os << i ;

}

Or

#include <iostream>

std::ostream & << (std::ostream& os, int i)
{
  return os << i ;
}

猜你喜欢

转载自www.cnblogs.com/2018shawn/p/10198419.html