现在的位置: 首页 > 综合 > 正文

error C2679: binary ‘<<‘ : no operator defined which takes a right-hand operand of type ” (or there is no acceptable conversion

2013年10月08日 ⁄ 综合 ⁄ 共 507字 ⁄ 字号 评论关闭

简单程序

#include <iostream.h>
#include <string>
#include <list>
#include <algorithm>

using namespace std;

PrintIt (string& StringToPrint) {
 std::cout<<StringToPrint<<endl;
//; cout<<"asdfds"<<endl;
}

int main (void) {
  list<string> FruitAndVegetables;
  FruitAndVegetables.push_back("carrot");
  
  for_each  (FruitAndVegetables.begin(), FruitAndVegetables.end(), PrintIt);
}
 

如果 #include <iostream.h> 则有错误,
错误如题所示:

error C2679: binary '<<' : no operator defined which takes a right-hand operand of type '' (or there is no acceptable conversion)

把其中的 “.h”去掉,则错误消失,能够正常运行!

抱歉!评论已关闭.