October 1999
Beginner
304 pages
7h 11m
English
Here is a partial definition of our BinaryTree class template:
template <typename elemType>
class BinaryTree {
public:
BinaryTree();
BinaryTree( const BinaryTree& );
~BinaryTree();
BinaryTree& operator=( const BinaryTree& );
bool empty() { return _root == 0; }
void clear();
private:
BTnode<elemType> *_root;
// copy a subtree addressed by src to tar
void copy( BTnode<elemType>*tar, BTnode<elemType>*src );
}; Defining an inline member function for a class template is the same as for a nonclass template, as the definition of empty() illustrates. The syntax for defining a class template member function outside the class body, however, looks very different, at least at first blush:
template <typename elemType> ...
Read now
Unlock full access