标题:编译通不过,咋办?
只看楼主
苍穹之舞
Rank: 2
等 级:论坛游民
威 望:1
帖 子:62
专家分:35
注 册:2014-10-7
结帖率:87.5%
已结贴  问题点数:20 回复次数:4 
编译通不过,咋办?


#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)
搜索更多相关主题的帖子: Documents include 
2017-05-31 08:56
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:507
帖 子:8890
专家分:53117
注 册:2011-1-18
得分:20 
#include "iostream.h"
改为
#include <iostream>
2017-05-31 09:48
苍穹之舞
Rank: 2
等 级:论坛游民
威 望:1
帖 子:62
专家分:35
注 册:2014-10-7
得分:0 
以下是引用rjsp在2017-5-31 09:48:06的发言:

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

通过了,这里头有什么奥秘?
2017-05-31 10:04
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:507
帖 子:8890
专家分:53117
注 册:2011-1-18
得分:0 
回复 3楼 苍穹之舞
iostream.h 上个世纪就被C++废弃了,那时候还没 std::string

2017-05-31 10:18
苍穹之舞
Rank: 2
等 级:论坛游民
威 望:1
帖 子:62
专家分:35
注 册:2014-10-7
得分:0 
以下是引用rjsp在2017-5-31 10:18:36的发言:

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

受教
2017-05-31 10:31



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-477480-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.136992 second(s), 9 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved