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

error C2039: 'push_back' : is not a member of 'basic_string请问是怎么回事?

韩雨航 发布于 2012-02-09 23:31, 3191 次点击
#include<iostream>
#include<fstream>
#include<algorithm>
#include<string>
using namespace std;
//----------------------
int main()
{
    ifstream in("remainder.txt");
    for(string s,t,u;in>>s>>t;u="")
    {
        sort(s.begin(),s.end());
        sort(t.begin(),t.end());
        cout<<s<<endl;
        cout<<t<<endl;
        set_difference(s.begin(),s.end(),t.begin(),t.end(),back_inserter(u));
        cout<<u<<endl;
    }
}

e:\vc6.0\microsoft visual studio\vc98\include\iterator(82) : error C2039: 'push_back' : is not a member of 'basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
        e:\vc6.0\microsoft visual studio\vc98\include\iterator(82) : while compiling class-template member function 'class std::back_insert_iterator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > &__thiscal
l std::back_insert_iterator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::operator =(const char &)'
执行 cl.exe 时出错.

剩余串排列1.obj - 1 error(s), 0 warning(s)
2 回复
#2
hahayezhe2012-02-10 08:30
你把string当STL的容器用...
#3
韩雨航2012-02-11 22:26
回复 2楼 hahayezhe
请问怎么改?
1