| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
共有 856 人关注过本帖
标题:string在cout的时候出了转换的问题
取消只看楼主 加入收藏
nubore
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2010-9-14
结帖率:50%
收藏
 问题点数:0 回复次数:0 
string在cout的时候出了转换的问题
程序代码:
#include <iostream>
#include <cstring>

using namespace std;

...
...
...


void TestType()
    {
        string Type;
        if ( TypeOfTaxer == 's' || TypeOfTaxer == 'S' )
            Type = "Single";
        else if ( TypeOfTaxer == 'm' || TypeOfTaxer == 'M' )
            Type = "Married";
        else if ( TypeOfTaxer == 'w' || TypeOfTaxer == 'W' )
            Type = "Widowed";
        else if ( TypeOfTaxer == 'd' || TypeOfTaxer == 'D' )
            Type = "Divorced";
        else if ( TypeOfTaxer == 'h' || TypeOfTaxer == 'H' )
            Type = "Head of Family";
        else
            Type = "None";

        cout << "\n\n\tFor This Year, You Declared Yourself as : "  << Type << " !\n";
    }

在 << Type 的时候出错, 我的string用法写错了?

error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
c:\program files (x86)\microsoft visual studio 10.0\vc\include\ostream(679): could be 'std::basic_ostream<_Elem,_Traits> &std::operator <<<char,std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const char *)'
搜索更多相关主题的帖子: color 
2011-02-06 09:35
快速回复:string在cout的时候出了转换的问题
数据加载中...
 
   



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

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