I want to extend a class throught private inheritance.
the base class is: Graph<T>
The derived is: Tree<T>
We know that a tree is a particular graph, so i want to extend my Graph class without letting user use the PUBLIC methods of Graph class.
Making:
template <typename T> class Tree : public Graph<T>{
.
.
.
}
works but i don't want to alter my tree state with Graph class methods. Users must use Tree class specific methods. I think i should use private inheritance to get what i want.
The problem is that i can't lose the "is a" relationship, because a Tree is, as a matter of fact, a graph.
What is a good design in order to make things good and semantically ordered?
Thanks