C++ Programming - Constructors and Destructors - Discussion
Discussion Forum : Constructors and Destructors - General Questions (Q.No. 8)
8.
Which of the following statement is incorrect?
Discussion:
34 comments Page 2 of 4.
Aaryya said:
1 decade ago
Answer provided here is wrong because constructor must be declared in public section.
Ashish said:
1 decade ago
Compiler provides default constructor with no argument.
Then how can 2nd option be incorrect?
Then how can 2nd option be incorrect?
Kapil Bablani said:
1 decade ago
Construtor cannot be private nor protected. It can only be public. Its a fact.
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.
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.
Pran said:
1 decade ago
How this answer is possible, as a constructor is always defined in public section of a class ?
Prem said:
1 decade ago
Compiler does not always provide zero value constructor. It does provide one such constructor when no other constructors are defined.
Abirami said:
1 decade ago
The option B will be correct as the compiler will not provide default constructor when user defined any constructor.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers