c++这是什么错误?

来源:百度知道 编辑:UC知道 时间:2024/06/12 14:54:55
#include <string>
#include<iostream.h>
using namespace std;
void main()
{
string str="aa";
cout<<str;
}

C:\Documents and Settings\admin\桌面\Cpp1.cpp(7) : 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 acce
ptable conversion)
执行 cl.exe 时出错.

Cpp1.exe - 1 error(s), 0 warning(s)

哎呀 你的头文件用错了 应该用新版头文件#include<iostream>

#include <string>
#include<iostream>
using namespace std;
void main()
{
string str="aa";
cout<<str<<endl;
}

#include<iostream>

头文件用错
#include<iostream>

#include <string>
#include<iostream>
using namespace std;
void main()
{
string str="aa";
cout<<str;
}

同一楼,
#include <string>
#include<iostream>
using namespace std;
void main()
{
string str="aa";
cout<<str;
}