O'Reilly logo

C++ Common Knowledge: Essential Intermediate Programming by Stephen C. Dewhurst

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Item 50. Member Templates

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:

image

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required