C++ Programming - Constructors and Destructors - Discussion

Discussion Forum : Constructors and Destructors - General Questions (Q.No. 34)
34.
Which of the following statements are correct?
Constructor is always called explicitly.
Constructor is called either implicitly or explicitly, whereas destructor is always called implicitly.
Destructor is always called explicitly.
Constructor and destructor functions are not called at all as they are always inline.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
9 comments Page 1 of 1.

Rsadhu said:   1 decade ago
class T
{
public:
T(){}
~T(){}
};


int main(void)
{
T a;
T * b = new T;
delete b;
}

/*
a object's destructor is implicitly called when a goes out of scope.

b object's destructor is called explicitly when delete b is called.
*/

So I am not ready to accept this as an answer.

Divya said:   1 decade ago
Constructor as well as destructor both can be called implicitly and explicitly.

Rajan said:   9 years ago
Yes, you are right @Divya.

Kartheek said:   9 years ago
Constructor and destructor both call implicitly and explicitly.

Akshay said:   9 years ago
Java provides destructor implicitely.

Shubham said:   6 years ago
The constructor can call implicitly but destructor can call implicitly as well implicitly.

Arjun Mandavkar said:   4 years ago
@Rsadhu.

Constructor can only be called implicitly on objects. But destructor can be called implicitly or explicitly.
(1)

Raonee said:   3 years ago
Constructor is always called implicitly whereas Destructor can be called either implicitly or explicitly both ways.
(1)

Tan said:   3 years ago
Yes, you are right @Raonee.

Post your comments here:

Your comments will be displayed after verification.