📄 test_iter.cpp
字号:
// test_Iter.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
// list_erase.cpp
// compile with: /EHsc
#include <list>
#include <iostream>
int main( )
{
using namespace std;
list <int> c1;
list <int>::iterator Iter;
c1.push_back( 10 );
c1.push_back( 20 );
c1.push_back( 30 );
c1.push_back( 40 );
c1.push_back( 50 );
cout << "The initial list is:";
for ( Iter = c1.begin( ); Iter != c1.end( ); Iter++ )
cout << " " << *Iter;
cout << endl;
//cout << * Iter+1;
//c1.erase( c1.begin( ) );
list <int> ::iterator iter1=c1.begin();
c1.erase( iter1);
cout<<*(c1.begin()+1)<<endl;
cout<<"..........................."<<*iter1<<"................."<<endl<<endl;
cout << "After erasing the first element, the list becomes:";
for ( Iter = c1.begin( ); Iter != c1.end( ); Iter++ )
cout << " " << *Iter;
cout << endl;
Iter = c1.begin( );
Iter++;
c1.erase( Iter, c1.end( ) );
cout << "After erasing all elements but the first, the list becomes: ";
for (Iter = c1.begin( ); Iter != c1.end( ); Iter++ )
cout << " " << *Iter;
cout << endl;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -