1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
#include<iostream>
#include<list>
using namespace std;
int main()
{
int testint[]={3, 5, 8, 14, 24, 28, 44, 67, 89, 92};
list<int> listint(testint, testint+10);
listint.insert(listint.begin(), 101); //insert one element
listint.insert(listint.begin(), 3, 102); //insert three elements of 102
listint.insert(listint.begin(), testint+2, testint+5); //insert by a pair of iterator
listint.insert(listint.begin()); //insert with default value (can't work)
//compiler gives an error that is no matching function
list<int>::iterator iter=listint.begin();
for(; iter!=listint.end(); ++iter)cout<<*iter<<" ";
}
| |