X
Xu, Feng
Now I am playing with STL. Here is the code:
//file name stl.C
#include <list>
#include <iostream>
#include <cstdlib>
#include <iterator>
using namespace std;
int main(int, char **){
cout<<"start:";
list<int> deck;
for(int i=1;i++;i<19)
{
deck.push_back(i);}
cout<<"finishing building:";
list<int>::iterator it=deck.begin();
do{
cout<<*it;
it++;}while(it!=deck.end());
return 1;
}
The code get compiled (g++ stl.C -o stl)
but when I tried to run the code, the program cosumed up to 1.6G memory,
and after print out "start", the program was terminated by the sysytem
because it run out of memory.
what's wrong with this code, I have tested with queue, stack, it runs
fine. But I have memory problem when I tried to use deque, list.
//file name stl.C
#include <list>
#include <iostream>
#include <cstdlib>
#include <iterator>
using namespace std;
int main(int, char **){
cout<<"start:";
list<int> deck;
for(int i=1;i++;i<19)
{
deck.push_back(i);}
cout<<"finishing building:";
list<int>::iterator it=deck.begin();
do{
cout<<*it;
it++;}while(it!=deck.end());
return 1;
}
The code get compiled (g++ stl.C -o stl)
but when I tried to run the code, the program cosumed up to 1.6G memory,
and after print out "start", the program was terminated by the sysytem
because it run out of memory.
what's wrong with this code, I have tested with queue, stack, it runs
fine. But I have memory problem when I tried to use deque, list.