64,682
社区成员
发帖
与我相关
我的任务
分享
/*
Detail: 编写程序处理一个string 类型的list容器。在该容器中寻找一个特殊值
如果找到,则将它删除掉。用deque重写。
Date: 2009年 7月 12日 22时 16分 37秒 星期日
*/
#include <iostream>
#include <list>
#include <deque>
#include <algorithm>
#include <cstdlib>
using namespace std;
int main ( void )
{
char * c_strTest[] = { "haha","gao","yan","xiao" };
list<string> lst_strTest( c_strTest, c_strTest + 4 );
deque<string> deq_strTest( c_strTest, c_strTest + 4 );
list<string>::iterator lst_strIndex = find( lst_strTest.begin(), lst_strTest.end(), "yan" );
deque<string>::iterator deq_strIndex = find( deq_strTest.begin(), deq_strTest.end(), "gao" );
if( lst_strIndex != lst_strTest.end() )
lst_strTest.erase( lst_strIndex );
if( deq_strIndex != deq_strTest.end() )
deq_strTest.erase( deq_strIndex );
//list<string>::iterator lst_strPut = lst_strTest.begin();
//deque<string>::iterator deq_strPut = deq_strTest.begin();
cout << "lst_strTest:" << endl;
//while( (lst_strPut++) != lst_strTest.end() )
// cout << *lst_strPut << endl;
for(list<string>::iterator lst_strPut = lst_strTest.begin();
lst_strPut != lst_strTest.end();
++lst_strPut )
cout << *lst_strPut << endl;///////////////////////////////////这句报错,信息在最下面
cout << "------------------------------------" << endl;
//cout << "deq_strTest:" << endl;
//while( (deq_strPut++) != deq_strTest.end() )
// cout << *deq_strPut << endl;
//cout << "------------------------------------" << endl;
system( "pause" );
return 0;
}
//error C2679: 二进制“<<”: 没有找到接受“std::basic_string<_Elem,_Traits,_Ax>”类型的右操作数的运算符 (或没有可接受的转换)
#include <string>