标题: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



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




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

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