Classes with No Class 161
41 data(NULL), next(NULL) {}
42 };
43 //----------------------------------------
44
45 node *first; // First node in the list
46
47 /*
48 * Delete the data for the node.
49 * Because we don't know what type of
50 * data we have,the derived class does
51 * the work of deleting the data
52 * through the delete_data function.
53 */
54 virtual void delete_data(void *data) = 0;
55 public:
56 // Delete all the data in the list
57 void clear(void) {
58 while (first != NULL)
59 {
60 // Pointer to the next node
61 class node *next;
62
63 next = first->next;
64 delete_data(first->data);
65 delete first;
66 first = next;
67 }
68 }
69
70 // Constructor
71 list(void): first(NULL) {};
72
73 // Destructor. Delete all data
74 virtual ~list(void) {
75 clear();
76