Explain the use of Vtable.

Explain the use of Vtable.

- Vtables are used for virtual functions. Its a shortform for Virtual Function Table.
- It's a static table created by the compiler. Compiler creates a static table per class and the data consists on pointers to the virtual function definitions. They are automatically initialised by the compiler's constructor code.
- Since virtual function pointers are stored in each instance, the compiler is enabled to call the correct vrtual function at runtime.

Explain the use of Vtable.

- If Base declares a member function and Derived declares a member function with same name but different parameter types, then the Base function is "hidden" rather than "overloaded" or "overridden" even if the Base function is virtual.
- The solution to that is that a Derived must have a using declaration of the hidden member function OR redefine the hidden Base member function(s), even if they are non-virtual.
- Normally this re-definition merely calls the hidden Base member function using the :: syntax.
Explain the problem with overriding functions
Explain the problem with overriding functions - Overriding of functions occurs in Inheritance. A derived class may override a base class member function.....
Overloading vs. overriding
Overloading vs. overriding - Overriding of functions occurs when one class is inherited from another class. Overloading can occur without inheritance. ....
What is virtual destructor? What is its use?
What is virtual destructor? What is its use? - If the destructor in the base class is not made virtual, then an object that might have been declared....
Post your comment