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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What is an inline function in c++?

627


What is encapsulation in c++?

674


What is scope in c++ with example?

630


What is the purpose of templates in c++?

563


What is a dynamic binding in c++?

536






What is one dimensional array in c++?

580


Why is c++ called oops?

557


Explain the concept of dynamic allocation of memory?

617


What is a volatile variable in c++?

556


What is late binding c++?

543


What is helper in c++?

573


What is singleton class in c++?

593


Why is main function important?

587


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

713


What is the use of seekg in c++?

599