Virtual Functions Flashcards
what is override?
To help address the issue of functions that are meant to be overrides but aren’t, C++11 introduced the override specifier. Override can be applied to any override function by placing the specifier in the same place const would go. If the function does not override a base class function, the compiler will flag the function as an error.
what is final specifier when related to functions
It means we cannot override this function anymore
what is final specifier when related to class inheritance
it means this class cannot be inherited further
what is interface class?
when all the members of the class are pure virtual functions then that class is interface class.
Interface class just provides a placeholder for specifying what all functionality should be present in the base class and its upto the derived classes to implement the functionality the way they want
what is pure virtual function?
virtual function whose body is set to 0 is a pure virtual function
what is abstract class?
A class with one or more pure virtual function is abstact class and we cannot instantiate or have an object of abstract class.
Do Abstract classes have a virtual table?
Yes abstract classes have a virtual table.
Abstract classes still have virtual tables, as these can still be used if you have a pointer or reference to the abstract class. The virtual table entry for a pure virtual function will generally either contain a null pointer, or point to a generic function that prints an error (sometimes this function is named __purecall) if no override is provided