How to construct virtual constructor

Answer Posted / nishant

Firstly Virtual constructor is really not needed at all.
Explanation:
V-table is something which stores the addresses corrospond
to all virtual function within a class.Now every class
object contains virtual pointer points to base address of
v-table in memory which is being used to resolve the
corrosponding virtual function addresses.

This v-table construction is done when object of the class
has been created,While constructor is an initialization
process in construction of the object and so v-table is not
available during initialization process and hence virtual
constructor is not possible.

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a C++ Program to check whether a number is prime number or not?

621


What is difference between rand () and srand ()?

579


How do you show the declaration of a virtual constructor?

520


What are the restrictions apply to constructors and destructors?

629


How does work in c++?

579






What do nonglobal variables default to a) auto b) register c) static

633


What is the difference between reference and pointer?

604


What is an incomplete type in c++?

753


What is copy constructor? Can we make copy constructor private in c++?

579


What is the use of 'using' declaration in c++?

612


Can you write a function similar to printf()?

655


What is the v-ptr?

622


Differentiate between a pointer and a reference with respect to c++.

683


What is c++ stringstream?

589


Why do we use vector in c++?

584