What are the fields of vtable
Answer / chandra
Vtable consists of function pointers pointing to the
virtual functions of their respective class.
Ex: Class A
{
public:
virtual void fun1();
virtual void fun2();
};
Class B: public A
{
public:
Virtual void fun2();
};
Now there will be 2 vtables created for the 2 classes. in
first vtable there will be 2 function pointers pointing to
fun1 and fun2.
one more vtable is created for the class B. in which this
vtable also consists of two function pointers because class
B is derived from class A. so all the functions are
derived . so in this vtable two function pointers are
present. one function pointer pointing to fun1 and one more
function pointer pointing to fun2 of derived class.
Is This Answer Correct ? | 4 Yes | 0 No |
In c++ there is only virtual destructors, no constructors. Why?
wht is major diff b/w c and c++?
wht is ditch
How to hide the base class functionality in Inheritance?
suppose A is a base class and B is the derved class. Both have a method foo which is defined as a virtual method in the base class. You have a pointer of classs B and you typecast it to A. Now when you call pointer->foo, which method gets called? The next part of the question is, how does the compiler know which method to call?
What is the example of polymorphism?
I hv a same function name,arguments in both base class and dervied class, but the return type is different. Can we call this as a function overloading? Explain?
pointers are support in C#? if yes then how to use it?
8 Answers Softvision Solution,
What is the difference between pass by value,pass by pointer,pass by reference in the catch block in the exception handling in c++
In OverLoading concept,Why they are not consider return value and why they are consider only parameters in method? For ex: public int Add(int a,int b){...} public String Add(int a,int b){...}
What is overriding in oops?
Should you protect the global data in threads? Why or why not?