Explain calling an object's member function(declared
virtual)from its constructor?



Explain calling an object's member function(declared virtual)from its constructor?..

Answer / deepak

It will depend on when pointer to vtable is initialised.
generally if constructor is already defined compiler insert
code to initialise virtual table pointer as first statement
inside defined constructor. If vptr is initialised before
calling virtual function then it will be invoked, if vptr is
not initialised then it can crash.

Is This Answer Correct ?    2 Yes 1 No

Post New Answer

More C++ General Interview Questions

What language is a dll written in?

0 Answers  


What is an inclusion guard?

0 Answers  


what is the difference between linear list linked representaion and linked representation? what is the purpose of representing the linear list in linked represention ? is it not avoiding rules of linear represention?

0 Answers  


Can I have a reference as a data member of a class? If yes, then how do I initialise it?

0 Answers  


Do class declarations end with a semicolon? Do class method definitions?

0 Answers  






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

0 Answers  


What is problem with overriding functions?

0 Answers  


What are the rules for naming an identifier?

0 Answers  


How to tokenize a string in c++?

0 Answers  


When do you call copy constructors?

0 Answers  


What is the most useful programming language?

0 Answers  


What is c++ iterator?

0 Answers  


Categories