65,211
社区成员
发帖
与我相关
我的任务
分享
ex:
A.h
class A
{
A();
~A();
list <int> list1;//分号
list <int> list2(10);
}
// constructing lists
#include <iostream>
#include <list>
using namespace std;
int main ()
{
// constructors used in the same order as described above:
list<int> first; // empty list of ints
list<int> second (4,100); // four ints with value 100
list<int> third (second.begin(),second.end()); // iterating through second
list<int> fourth (third); // a copy of third
// the iterator constructor can also be used to construct from arrays:
int myints[] = {16,2,77,29};
list<int> fifth (myints, myints + sizeof(myints) / sizeof(int) );
cout << "The contents of fifth are: ";
for (list<int>::iterator it = fifth.begin(); it != fifth.end(); it++)
cout << *it << " ";
cout << endl;
return 0;
}