How the V-Table mechanism works?

Answers were Sorted based on User's Feedback



How the V-Table mechanism works?..

Answer / dee

V-table is created for class when a class has atleast one
virtual function and each virtual function has a entry in
the V-table.

Is This Answer Correct ?    48 Yes 3 No

How the V-Table mechanism works?..

Answer / nishikant sahu

V-Table holds the addresses of virtual functions of a class
and type_info structure for RTTI.V-table created class basis.
when an object created compiler secretly inserted the
v-table pointer of the respective class and then Vptr
iterator accordingly. all are done under the hood.

Is This Answer Correct ?    21 Yes 3 No

How the V-Table mechanism works?..

Answer / ramesh

V-table is specific to class. No matter how many objects
are created for this class, only one virtual table exists.
Each virtual function in the class will have a pointer in
Vtable.

Whenever a code like Base *b = new Derived; is encountered,
during compile time the search will happen in Base class.
Its only during run time the actual objects are invoked and
the fucntion present in derived class will be called.

Is This Answer Correct ?    6 Yes 1 No

How the V-Table mechanism works?..

Answer / deepa balamurugan

If the both Base and the Derived class having the same
function then the Base class funtion should be declared as
virtual function. Then the C++ determines which function to
be called at the runtime based on the type of the object
pointed to by the Base pointer rather than the type of the
pointer.
As soon as the compiler reads the keyword virtual ,it will
create the vtable contains the address of the virtual
function inside that class and as soon as vtable is
created ,vptr is initialized to the proper vtable.

Is This Answer Correct ?    3 Yes 0 No

How the V-Table mechanism works?..

Answer / tiru

virtual table contains the address of the virtual functions
and pointers to the objects of the each of the derived
classes.

Is This Answer Correct ?    6 Yes 12 No

How the V-Table mechanism works?..

Answer / achal

V-Table mechanism works on principle of dynamic binding
i.e. which version of the function has to be called is
decided by CPU at run time.
Use of virtual functions make the execution slower. Not all
the objects of the same class have different V-Table.

Is This Answer Correct ?    2 Yes 10 No

Post New Answer

More C++ General Interview Questions

What do you know about friend class and friend function?

1 Answers  


Out of fgets() and gets() which function is safe to use and why?

0 Answers  


Problem 6: Area of a trapezoid can be calculated by the following formula: A=(b1 b2)×h2 where b1 and b2 are the parallel sides or the bases and h is length of height Write a C code of this program

0 Answers   Maxobiz,


How important is c++?

0 Answers  


What are the advantages of c++? Explain

0 Answers  






What is the use of namespace std in C++?

0 Answers   Hexaware,


Why c++ is created?

0 Answers  


Write a program that will count the number of digits in an input integer up to value MAX_VALUE (2147483647). Thus, for an input of 5837 the output should be 4 digits Make sure that your program works for the numbers 0, 1, and 10. For the number 0, the output should be 1 digit

2 Answers  


what is software cycle? What is a mission critical system ? What is the important aspect of a real-time system ? Explain the difference between microkernel and macro kernel. Give an example of microkernel.Why paging is used ? Which is the best page replacement algo and Why ? What is software life cycle ? How much time is spent usually in each phases and why Which one do U want to work if selected in Honeywell ? Which are the different types of testing ? What is a distributed system ? Some questions about CSP. Which languages do U know ? What are the differences between Pascal and C. questions from Compiler construction and Lisp. Which are the different computer architecture? What is the requirement in MIMD ? What is the difference between RISC and CISC processors ? Difference between loosely coupled and tightly coupled systems ? What is an open system?

0 Answers   Honeywell,


Should the member functions which are made public in the base class be hidden?

0 Answers  


Define the process of handling in case of destructor failure?

0 Answers  


What happens when a function throws an exception that was not specified by an exception specification for this function?

1 Answers  


Categories