Suppose I have a class BST and a child class RBT. The class BST has a wrapper function as follows:
void BST::walk(ostream& to)
{
inorder_walk(root, to);
}
Where inorder_walk
is a virtual function. When I have a new virtualized inorder_walk
function in my RBT class, do I need to make walk
virtual as well, even though in both classes all walk
needs to do is call inorder_walk
? That is, although the walk
function isn't virtual, when it calls a virtual function inside of it, does C++ know to call the virtualized function? Thanks in advance for your answers!
No, you do not need to make it virtual.