Skip to content
Related Articles

Related Articles

C++ | Constructors | Question 14
  • Last Updated : 29 Aug, 2013

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.

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

Quiz of this Question

Want to learn from the best curated videos and practice problems, check out the C Foundation Course for Basic to Advanced C.
My Personal Notes arrow_drop_up
Recommended Articles
Page :