(a) 
template <typename T>
struct list_node {
  T* data; // The data itself.
  list_node* next; // The next element in the list.
};

(b) 
if (x->next->data > 7)
  y->next = y->next->next;
if (x->next->data % 2 == 0)
  x->data = x->data + 4;

Example 10: Generic list in C++. (a) Type definition; (b) sample code modifying a list node.

Back to Article