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

Explain the operation of overloading of an assignment operator.

791


Can constructor be static in c++?

761


Are iterators pointers?

773


What is the difference between an external iterator and an internal iterator? Describe an advantage of the external iterator.

671


What does catch(…) mean?

722






Write some differences between an external iterator and an internal iterator?

677


Write about the local class and mention its use?

729


What is c++ array?

636


What is java and c++?

745


Explain the problem with overriding functions

682


What is a list c++?

672


Is there any function that can skip certain number of characters present in the input stream?

667


What is the latest version on c++?

773


Write a program to add three numbers in C++ utilizing classes.

721


How the endl and setw manipulator works?

649