In C++, virtual functions can be private and can be overridden by the derived class. For example, the following program compiles and runs fine.
There are few things to note in the above program.
1) ptr is a pointer of Base type and points to a Derived class object. When ptr->fun() is called, fun() of Derived is executed.
Note that this behavior is totally different in Java. In Java, private methods are final by default and cannot be overridden (See this)
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above