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
Write a C++ Program to check whether a number is prime number or not?
What is difference between rand () and srand ()?
How do you show the declaration of a virtual constructor?
What are the restrictions apply to constructors and destructors?
How does work in c++?
What do nonglobal variables default to a) auto b) register c) static
What is the difference between reference and pointer?
What is an incomplete type in c++?
What is copy constructor? Can we make copy constructor private in c++?
What is the use of 'using' declaration in c++?
Can you write a function similar to printf()?
What is the v-ptr?
Differentiate between a pointer and a reference with respect to c++.
What is c++ stringstream?
Why do we use vector in c++?