Can we call a virtual function from a constructor?



Can we call a virtual function from a constructor?..

Answer / hrpynux@gmail.com

You can call a virtual function in a constructor, but be careful. ... In a constructor, the virtual call mechanism is disabled because overriding from derived classes hasn't yet happened. Objects are constructed from the base up, “base before derived”.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ Interview Questions

Difference between Call by pointer and by reference.

0 Answers   Adobe,


Write a program to display the following output using a single cout statement Maths=90 Physics=77 Chemistry = 69

2 Answers  


What Is Polymorphism in C++ ?

2 Answers   IBS, Impetus, ITC Indian Tobacco Company, Motorola,


What is the purpose of a constructor? Destructor?

0 Answers   Amazon,


Write a C++ Program to Display Number (Entered by the User).

1 Answers  


What are "pure virtual" functions?

0 Answers   Adobe, Alter, iNautix,


When must you use a constructor initializer list?

0 Answers   Amazon,


How to convert integer to string in C++

0 Answers  


How to run C++ program in cmd

0 Answers  


What are the different scope C++ provide ?

0 Answers   Amdocs,


If class D is derived from a base class B

0 Answers  


Execute the qsort () in c/sort() in c++ library or your own custom sort which will sort any type of data on user defined criteria.

0 Answers   Adobe,


Categories