#include #include using namespace std; struct node { char c; int i; double d; node( char c, int i, double d ) : c(c), i(i), d(d) {} }; // node int main() { list top; // create doubly linked list int i; for ( i = 0; i < 10; i += 1 ) { // create list nodes node n( 'a' + i, i, (double)i + 0.5 ); top.push_back( n ); // copy node at end of list } // for list::iterator li; // iterator for doubly linked list for ( li = top.begin(); li != top.end(); ++li ) { // traverse list nodes cout << "c:" << li->c << " i:" << li->i << " d:" << li->d << endl; } // for cout << endl; while ( 0 < top.size() ) { // destroy list nodes node n = top.front(); // copy node at front of list top.pop_front(); // remove first node cout << "c:" << n.c << " i:" << n.i << " d:" << n.d << endl; } // while if ( top.empty() ) { // verify list nodes destroyed cout << endl << "list is empty" << endl; } // if } // main