What is the purpose of a pure virtual function in C++? 

  • To provide default functionality 
  • To force derived classes to provide an implementation 
  • To enhance runtime performance 
  • To prevent method overloading
A pure virtual function in C++ is declared using "= 0" and doesn't have an implementation in the base class. It's a way to ensure that derived classes provide their own implementation of the function, effectively making the base class abstract. This ensures a consistent interface.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *