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

What is the difference between the functions memmove() and memcpy()?

720


How many standards of c++ are there?

724


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

679


What are the various operations performed on stack?

706


What is the difference between method overloading and method overriding in c++?

647






How many types of classes are there in c++?

684


What is the difference between a definition and a declaration?

661


Describe the role of the c++ in the tradeoff of safety vs. Usability?

813


Which one is a preferred language C or C++? Why?

708


Write a struct time where integer m, h, s are its members?

607


What are the defining traits of an object-oriented language?

788


What are the comments in c++?

656


What is the difference between while and do while loop? Explain with examples.

688


What is #include iomanip?

635


What is the best c++ book for beginners?

684