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 is difference between class and function?

0 Answers  


Find the second maximum in an array?

12 Answers   HCL,


What is c++ hiding?

0 Answers  


Write any small program that will compile in "C" but not in "C++"?

4 Answers  


what are the iterator and generic algorithms.

0 Answers  


What are virtual constructors/destructors?

0 Answers  


In C++ cout is: a) object b) class c) something else

11 Answers   Infosys, Lehman Brothers,


What is the purpose of the noexcept keyword?

1 Answers  


Can circle be called an ellipse?

0 Answers  


What C++ libraries are you proficient with?

1 Answers   Google,


What data encapsulation is in c++?

0 Answers  


What is conversion constructor?

2 Answers   TCS,


Categories