先来段代码。我是在vs2012上实验的:
// priority_queue.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
//#include <map>
//#include <string>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
//map<int, string> mapStudent;
//mapStudent.insert(pair<int, string>(1,"zl"));
//mapStudent.insert(map<int, string>::value_type(2,"gs"));
//map<int, string>::iterator it;
//map<int, string>::reverse_iterator rit;
//for(it = mapStudent.begin(); it != mapStudent.end(); it++)
//{
// cout << it->first << " " << it->second << endl;
//}
//cout << "---------------" << endl;
//for(rit = mapStudent.rbegin(); rit != mapStudent.rend(); rit++)
//{
// cout << rit->first << " "<< rit->second << endl;
//}
string s("111111");
cout << s << endl;
return 0;
}
注意我注释掉了“ #include <string>"d然后编译器就报string没实现<<符号重载。
如果我把上面红色这句加上的话,就不会出现这样的问题。
具体问题我也不了解,可能怀疑是vs找到了另一个string类,而这个类是没有实现<<符号重载的。具体我也不太清楚啦