How to create a virtual function that must be redefined in all derivative classes?



  • How to create a virtual function that must be redefined in all derivative classes?



  • It's called pure virtual function:

    virtual void f() = 0;
    

    This makes the class abstract and indicates that descendants must redesign the method if a copy of the descendant is required. Otherwise, the derivative class will also be abstract.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2