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 data binding in c++?

512


Explain the auto storage classes in c++.

610


Define anonymous class.

629


what are the iterator and generic algorithms.

1469


Define copy constructor.

629






How do you add an element to a set in c++?

557


What is c++ in english?

587


Why c++ is better than c language?

573


What is a v-table?

655


How is objective c different from c++?

803


How do we balance an AVL Tree in C++?

652


What does 7/9*9 equal ? a) 1 b) 0.08642 c) 0

591


What is the most common mistake on c++ and oo projects?

530


Why is swift so fast?

632


Can a class be static in c++?

581