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

Define type casting in C++.

0 Answers   Amdocs,


What is a virtual base class?

6 Answers   Fidelity, Siemens,


explain the term 'resource acquisition is initialization'?

0 Answers   Amazon,


Explain the difference between method overriding and method overloading in C++?

0 Answers   Accenture,


What are "pure virtual" functions?

0 Answers   Adobe, Alter, iNautix,






Write a C++ Program to Find Sum and Average of three numbers.

1 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,


Write a C++ Program to Find Sum and Average of n numbers using for loop.

1 Answers  


Write a program that ask for user input from 5 to 9 then calculate the average

0 Answers   IBS,


How to run C++ program in cmd

0 Answers  


Describe the different styles of function prototypes in C++.

0 Answers   Adobe,


Consider the following C++ program

0 Answers  


Categories