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

Is c++ low level?

798


program explaining feautures of c++

2177


How to allocate memory dynamically for a reference?

795


Difference between an inspector and a mutator

1054


How do you declare a set in c++?

728


What is time h in c++?

869


What is the c++ programming language used for?

774


What do you mean by enumerated data type?

789


How are the features of c++ different from c?

804


What do you mean by delegate? Can a user retain delegates?

728


What is a storage class?

892


What is #include sstream?

811


Write a program which uses functions like strcmp(), strcpy()? etc

848


What is #include cmath?

845


what are the iterator and generic algorithms.

1906