Technical Discussion :: C++
Home > Technical Interview Q&A > C++ > Discussion
78 / 187
Difference between constructor and destructor?
Answer:
Constructor:
1. The constructor is a ‘special’ member function whose task is to initialize the objects of its class.
2. It constructs the values of data members of the class
Destructor:
1. The destructor is a member function whose name is the same as the class name but is preceded by a tilde.
2. It destroys the objects that have been created by a constructor.
Asked In ::
Amit Yadav
23 Feb, 2019 5:07 AM
Constructor:
1. The constructor is a ‘special’ member function whose task is to initialize the objects of its class.
2. It constructs the values of data members of the class
Destructor:
1. The destructor is a member function whose name is the same as the class name but is preceded by a tilde.
2. It destroys the objects that have been created by a constructor.
1. The constructor is a ‘special’ member function whose task is to initialize the objects of its class.
2. It constructs the values of data members of the class
Destructor:
1. The destructor is a member function whose name is the same as the class name but is preceded by a tilde.
2. It destroys the objects that have been created by a constructor.