Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

C++ | Constructors | Question 14

  • Last Updated : 28 Jun, 2021

Which of the following is true about constructors.
1) They cannot be virtual.
2) They cannot be private.
3) They are automatically called by new operator.
(A) All 1, 2, and 3
(B) Only 1 and 3
(C) Only 1 and 2
(D) Only 2 and 3


Answer: (B)

Explanation: 1) True: Virtual constructors don’t make sense, it is meaningless to the C++ compiler to create an object polymorphically.

2) False: Constructors can be private, for example, we make copy constructors private when we don’t want to create copyable objects. The reason for not making copyable object could be to avoid shallow copy.

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.

3) True: Constructors are automatically called by new operator, we can in-fact pass parameters to constructors.

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!