Homework/HW02/List.cc
void List::print()
{
    // print the count first
    cout << "The list has " << size << " nodes." << endl;

    if (size)   // if the list is not empty
    {
        // print all the nodes using an iterator
        cout << "Here are the nodes of the list:" << endl;
        ListIterator iter(head); //start from the head
        while (iter) // while we haven't reached the end
        {
            cout << *iter << ' '; // print the datum
            ++iter; // move to the next node
        }
        cout << endl;
    }
}
// Prints the list. We also want to know how many node are there in
// the list and if the list is empty.  I have rewriten this function
// using list iterators.
Prints the list. We also want to know how many node are there in
the list and if the list is empty.  I have rewriten this function
using list iterators.
Prints the list . We also want to know how many node are there in the list and if the list is empty . I have rewriten this function using list iterators .
void List::print()
{
    cout << "The list has " << size << " nodes." << endl;
    if (size)   
    {
        cout << "Here are the nodes of the list:" << endl;
        ListIterator iter(head); 
        while (iter) 
        {
            cout << *iter << ' '; 
            ++iter; 
        }
        cout << endl;
    }
}
void List :: print ( ) { cout << " " << size << " " << endl ; if ( size ) { cout << " " << endl ; ListIterator iter ( head ) ; while ( iter ) { cout << * iter << ' ' ; ++ iter ; } cout << endl ; } }
Prints the list.
Prints the list .
// print the count first // if the list is not empty // print all the nodes using an iterator //start from the head // while we haven't reached the end // print the datum // move to the next node