next up previous contents
Next: Testing the Overloaded Equal: Up: Using Various SLLIST Objects: Previous: Testing the delete Operator

Testing the Delete Operator from the Inside:

  {
  int input[10] = {1,3,4,5,6,11,8,11,9,10};

  cout << "Instantiating List Qaitlin" << endl;
  INT_SLLIST Qaitlin("intQa3");

  cout << endl << "Building Qaitlin List" << endl;
  Qaitlin.build_list(input,10);
  cout << "Qaitlin has " << Qaitlin.get_number_elements() << " elements";
  cout << endl;
  cout << endl << "Qaitlin = " << endl << Qaitlin << endl;

  cout << endl << "Delete the element 11 " << endl;
  Qaitlin.delete_element(11);
  cout << endl << "Qaitlin = " << endl << Qaitlin << endl;
  }

On this output, since the list to be deleted upon leaving scope has many elements, we see the nested SL_CELL destructor calls very clearly.

Instantiating List Qaitlin
In default SLLIST<intQa3> constructor.
Exit default SLLIST<intQa3> constructor.

Building Qaitlin List
In SLLIST<intQa3> build_list.
Exit SLLIST<intQa3> build_list.
Qaitlin has 10 elements
Qaitlin = 
1-->3-->4-->5-->6-->11-->8-->11-->9-->10.

Delete the element 11 

Qaitlin = 
1-->3-->4-->5-->6-->8-->9-->10.

Entering SLLIST<intQa3> destructor.
     Removing SL_CELL -1
         Removing SL_CELL 0
             Removing SL_CELL 1
                 Removing SL_CELL 2
                     Removing SL_CELL 3
                         Removing SL_CELL 4
                             Removing SL_CELL 5
                                 Removing SL_CELL 6
Leaving SLLIST destructor.



Jim Peterson
1999-04-22