注册 登录
编程论坛 C++教室

编译通不过,咋办?

苍穹之舞 发布于 2017-05-31 08:56, 2280 次点击
只有本站会员才能查看附件,请 登录


#include "stdafx.h"
#include "iostream.h"
#include  <string>
using namespace std;


int main()
{
    string x="7";
    string y="&";
    x+=y;
    x+="8";
    cout<<x<<endl;
}

编译出现如下提示:C:\Documents and Settings\Administrator\桌面\357357357\357357357.cpp(16) : 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)
4 回复
#2
rjsp2017-05-31 09:48
#include "iostream.h"
改为
#include <iostream>
#3
苍穹之舞2017-05-31 10:04
以下是引用rjsp在2017-5-31 09:48:06的发言:

#include "iostream.h"
改为
#include <iostream>

通过了,这里头有什么奥秘?
#4
rjsp2017-05-31 10:18
回复 3楼 苍穹之舞
iostream.h 上个世纪就被C++废弃了,那时候还没 std::string

#5
苍穹之舞2017-05-31 10:31
以下是引用rjsp在2017-5-31 10:18:36的发言:

iostream.h 上个世纪就被C++废弃了,那时候还没 std::string

受教
1