13.6 PURE VIRTUAL FUNCTIONS
If you believe that, the idea of virtual function has solved the problem. You are mistaken. Actually, the situation can be described as “akash se fisle Aur khajoor pe atke” (escaped from the sky and hung on a tree, meaning escaped from a big trouble but caught in a small trouble).
Imagine a case where you forget to declare (and define) a function move in any derived class object. If base class pointer is pointing to this object and you invoked move(), the computer will execute the base class move(). This is quite unacceptable. What is the solution? Pure virtual functions!
Most of the times, the idea behind of declaring a function (in the base class) virtual, is to stop its execution. Then the question arises why should ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access