采用List容器类,写的第二个STL演示程序.之后准备往其中填入自己的对象.
#include <iostream>
#include <string>
#include <list>
namespace std {} using namespace std;
int main()
{
string *myword;
myword=new string("List is:");
cout<< myword->c_str()<<endl;
delete myword;
list<int> L;
L.push_back(0);
L.push_front(1);
L.insert(++L.begin(), 2);
copy(L.begin(), L.end(), ostream_iterator<int>(cout, " "));
cout<<endl;
return 0;
}
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/