February 2005
Beginner to intermediate
272 pages
4h 53m
English
Class templates have members that are not themselves templates, and many of these members can be defined outside the class. Let’s look at a singly linked list container:

The member functions of a template, when defined outside the class template, have a template header with the same structure as that used in the class template definition:
template <typename T>bool SList<T>::empty() const { return head_ == 0; }
We’ve decided to implement our singly linked list as a pointer to a sequence of nodes, where each node contains a list element and a pointer to the next node on the list. (A more sophisticated implementation ...
Read now
Unlock full access