How can I reuse a base class function in a derived class

Posted by Armen Ablak on Stack Overflow See other posts from Stack Overflow or by Armen Ablak
Published on 2011-01-08T14:23:22Z Indexed on 2011/01/08 14:53 UTC
Read the original article Hit count: 231

Let's say we have these four classes:

  • BinaryTree,
  • SplayTree (which is a sub-class of BinaryTree),
  • BinaryNode and
  • SplayNode (which is a sub-class of BinaryNode).

In class BinaryTree I have 2 Find functions, like this

bool Find(const T &) const; 
virtual Node<T> * Find(const T &, Node<T> *) const;

and in SplayTree I would like to reuse the second one, because it works in the same way (for example) as in SplayTree, the only thing different is the return type, which is SplayNode.

I thought it might be enough if I use this line in SplayTree.cpp

using BinaryTree::Find;

but it isn't.

So, how can I do this?

© Stack Overflow or respective owner

Related posts about c++

Related posts about templates