注册 登录
编程论坛 VC++/MFC

各位高手能不能帮我看下哪错了?不胜感激啊

韩雨航 发布于 2012-01-13 00:14, 766 次点击
#include<iostream>
#include<algorithm>
using namespace std;
void main()
{
    string a,s1="hello";
    string s2="123";
    a=s1;                                        //复制
    cout<<(a==s1 ?"":"not ")<<"equal"<<endl;        //比较
    cout<<a+=s2<<endl;                            //连接
    reverse(a.begin(),a.end());                    //倒置串
    cout<<a<<endl;
    cout<<a.replace(0,9,9,'c')<<endl;            //设置
    cout<<(s1.find("ell")!=-1?"":"not")<<"found"<<endl;    //查找串
    cout<<(s1.find('c')!=-1?"":"not")<<"found"<<endl;    //查找字符
}


E:\程序\string字符串操作.cpp(10) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,const short *)' : could not deduce template argument for 'class std::basic_ostream<_E,_Tr> &' from 'class
std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
E:\程序\string字符串操作.cpp(10) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,const unsigned char)' : could not deduce template argument for 'class std::basic_ostream<_E,_Tr> &' from '
class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
E:\程序\string字符串操作.cpp(10) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,const unsigned char *)' : could not deduce template argument for 'class std::basic_ostream<_E,_Tr> &' from
 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
E:\程序\string字符串操作.cpp(10) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,const signed char)' : could not deduce template argument for 'class std::basic_ostream<_E,_Tr> &' from 'cl
ass std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
E:\程序\string字符串操作.cpp(10) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,const signed char *)' : could not deduce template argument for 'class std::basic_ostream<_E,_Tr> &' from '
class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
E:\程序\string字符串操作.cpp(10) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,_E)' : could not deduce template argument for 'class std::basic_ostream<_E,_Tr> &' from 'class std::basic_
string<char,struct std::char_traits<char>,class std::allocator<char> >'
E:\程序\string字符串操作.cpp(10) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,const _E *)' : could not deduce template argument for 'class std::basic_ostream<_E,_Tr> &' from 'class std
::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
E:\程序\string字符串操作.cpp(10) : error C2676: binary '<<' : 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' does not define this operator or a conversion to a type acceptable to the predefined operator
E:\程序\string字符串操作.cpp(12) : 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 conversio
n)
E:\程序\string字符串操作.cpp(13) : 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 conversio
n)
执行 cl.exe 时出错.

string字符串操作.exe - 1 error(s), 0 warning(s)
2 回复
#2
BianChengNan2012-01-19 19:08
#include<string>
#3
韩雨航2012-01-20 20:26
谢谢~~
1