Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

C++ | Virtual Functions | Question 14

  • Difficulty Level : Medium
  • Last Updated : 28 Jun, 2021

Can a constructor be virtual?

Will the following program compile?

Take a step-up from those "Hello World" programs. Learn to implement data structures like Heap, Stacks, Linked List and many more! Check out our Data Structures in C course to start learning today.

#include <iostream>
using namespace std;
class Base {
  virtual Base() {}   
int main() {
   return 0;

(A) Yes
(B) No

Answer: (B)

Explanation: There is nothing like Virtual Constructor. Making constructors virtual doesn’t make sense as constructor is responsible for creating an object and it can’t be delegated to any other object by virtual keyword means.

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!