C++ Programming - Constructors and Destructors - Discussion

Discussion Forum : Constructors and Destructors - General Questions (Q.No. 7)
7.
Which of the following statement is correct?
Constructor has the same name as that of the class.
Destructor has the same name as that of the class with a tilde symbol at the beginning.
Both A and B.
Destructor has the same name as the first member function of the class.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
4 comments Page 1 of 1.

Sameer said:   1 decade ago
Constructor is defined with the class name and deconstructor defines ~class name.

SOMYA AGRAWAL said:   1 decade ago
What is actually meaning of Destructor?

I think Destructor have the same name as Constructor not class name, all I meant that Destructor is made after the constructor only.

Ashwini Ardad said:   6 years ago
Constructor is same as class name and Destructor is rewrite with ~ symbol.

Smita B. said:   3 years ago
Both A and B are correct statements as constructors and destructor are special functions of class hence all constructors and destructor has the same name as that of class. There is only difference between constructors and destructor is, we have to write tilde symbol at the beginning of name of destructor so that compiler can search easily search for it and can delete whole memory.

Post your comments here:

Your comments will be displayed after verification.