- 论坛徽章:
- 0
|
想用copy的方法把deque的元素输出,结果就是报错 ,大家看看怎么回事?
代码:
[gag@genomic-server cpp]$ more deque.cpp
#include <iostream>;
#include <deque>;
#include <vector>;
#include <string>;
#include <algorithm>;
using namespace std;
int main()
{
deque<string>; coll;
vector<int>; a;
coll.assign( 3 , string("string" );
coll.push_back ( "last string" );
coll.push_front ( "first string" );
copy ( coll.begin(),coll.end(),
ostream_iterator<string>;(cout,"\n" );
cout << endl;
deque<string>;::const_iterator first_iter=coll.begin();
deque<string>;::const_iterator first_iter_end=coll.end();
for ( ; first_iter != first_iter_end; ++first_iter )
{
cout << *first_iter <<endl;
}
cout << endl << endl;
for ( int i =1 ; i<coll.size(); ++i )
{
coll="another" + coll;
}
deque<string>;::const_iterator second_iter=coll.begin();
deque<string>;::const_iterator second_iter_end=coll.end();
for ( ; second_iter != second_iter_end; ++second_iter )
{
cout << *second_iter <<endl;
}
cout << endl << endl << endl;
coll.resize(4,"resized string" );
deque<string>;::const_iterator third_iter=coll.begin();
deque<string>;::const_iterator third_iter_end=coll.end();
for ( ; third_iter != third_iter_end; ++third_iter )
{
cout << *third_iter <<endl;
}
} |
|