Virtual member functions
suggest changeSyntax
virtual void f();virtual void g() = 0;- C++11 or later:
virtual void h() override;void i() override;virtual void j() final;void k() final;
Remarks
- Only non-static, non-template member functions can be
virtual. - If you are using C++11 or later, it is recommended to use
overridewhen overriding a virtual member function from a base class. - Polymorphic base classes often have virtual destructors to allow a derived object to be deleted through a pointer to the base class. If the destructor were not virtual, such an operation leads to undefined behavior[expr.delete] ยง5.3.5/3 .
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents