Can we call a virtual function from a constructor?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What is endl c++?

610


Can you Mention some Application of C/C++?

628


When would you use a pointer? A reference?

590


Write a program in c++ to print the numbers from n to n2 except 5 and its multiples

2041


How new/delete differs from malloc()/free?

620






What are the general quetions are in DEna bank manager IT/System interviews?

1537


How do you define social class?

605


What is data binding in c++?

508


How many times will this loop execute? Explain your answer.

383


What is the difference between mutex and binary semaphore?

616


What does getch() do according to the ANSI C++ standard a) Reads in a character b) Checks the keyboard buffer c) Nothing in particular (Its not defined there)

606


what type of questions

1697


Write a program to reverse a string using recursive function?

1798


Write a program using merge () function to combine the elements of array x[ ] and y[ ] into array z[ ].

612


What is a forward referencing and when should it be used?

581