主题:有个小小的错误,不知怎么改
error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable conversion
)
这是个什么错误啊?就是按照书上输入的应该没有错误才对啊。
还有下面第一行#pragma warning (disable:4786)是什么意思啊?刚开始没有加这个时,总是有错误,后来看了别人程序,加上之后,就可以了。
#pragma warning (disable:4786)
#include <algorithm>
#include <map>
#include <iostream>
using namespace std;
int main()
{
map<int, string> mapStudent;
mapStudent.insert(map<int, string>::value_type (1, "student_one"));
mapStudent.insert(map<int, string>::value_type (2, "student_two"));
mapStudent.insert(map<int, string>::value_type (3, "student_three"));
map<int, string>::iterator iter;
for(iter = mapStudent.begin(); iter != mapStudent.end(); iter++)
{
cout<<iter->first;
cout<<""<<iter->second;
}
return 0;
}
)
这是个什么错误啊?就是按照书上输入的应该没有错误才对啊。
还有下面第一行#pragma warning (disable:4786)是什么意思啊?刚开始没有加这个时,总是有错误,后来看了别人程序,加上之后,就可以了。
#pragma warning (disable:4786)
#include <algorithm>
#include <map>
#include <iostream>
using namespace std;
int main()
{
map<int, string> mapStudent;
mapStudent.insert(map<int, string>::value_type (1, "student_one"));
mapStudent.insert(map<int, string>::value_type (2, "student_two"));
mapStudent.insert(map<int, string>::value_type (3, "student_three"));
map<int, string>::iterator iter;
for(iter = mapStudent.begin(); iter != mapStudent.end(); iter++)
{
cout<<iter->first;
cout<<""<<iter->second;
}
return 0;
}