| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1500 人关注过本帖
标题:string问题
取消只看楼主 加入收藏
幽灵嫖客
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2007-1-15
收藏
 问题点数:0 回复次数:3 
string问题
程序源码:
#include <iostream>
#include <cstring>
using namespace std;

int main()
{
    string strinfo="please input a string:\n";
    cout<<strinfo;
    cin>>strinfo;
    cout<<strinfo;
    return 0;
}

运行时报错了:
d:\vc++ 6.0\msdev98\myprojects\ycp\a.cpp(8) : 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 acceptabl
e conversion)
不知道为什么?
搜索更多相关主题的帖子: string 
2008-04-13 18:13
幽灵嫖客
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2007-1-15
收藏
得分:0 
可能是编译器装的时候就有问题,不可能没有重载string的》和《

C primer plus
2008-04-13 18:33
幽灵嫖客
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2007-1-15
收藏
得分:0 
不是说C++的头文件在C前加个'c'吗?
能解释一下吗?

C primer plus
2008-04-13 18:56
幽灵嫖客
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2007-1-15
收藏
得分:0 
但我用的是Visual C++ 6.0 如果包含cstring头文件
用cin读入一个string或用cout输出一个stirng时
就会报错误。

C primer plus
2008-04-14 16:53
快速回复:string问题
数据加载中...
 
   



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

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