C++ Programming - Constructors and Destructors - Discussion

Discussion Forum : Constructors and Destructors - General Questions (Q.No. 8)
8.
Which of the following statement is incorrect?
Constructor is a member function of the class.
The compiler always provides a zero argument constructor.
It is necessary that a constructor in a class should always be public.
Both B and C.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
34 comments Page 4 of 4.

Radhika said:   1 decade ago
Constructor is a special member function of class. So ALL the statements are correct.

Amit Kumar Giri said:   1 decade ago
My dear friends. Option D is correct.

Compiler by default provide public constructor. Constructor can be private. To implement singleton class we have to make constructor private. It is one of the design pattern.

Compiler provides default constructor with argument. In case of copy constructor called, by default compiler provides the constructor with the argument type of that class.

Manish said:   1 decade ago
Can we create static constructor?

Alex said:   1 decade ago
Have you heard of Singleton pattern? The constructor is private and the object is created via a static function.


Post your comments here:

Your comments will be displayed after verification.