| |
GeekInterview.com > Interview Questions > Programming > C++
| Print | |
Question: what is defference between constructor and destructor
|
| August 08, 2008 07:07:55 |
#5 |
| YaelG |
Member Since: July 2008 Total Comments: 1 |
RE: what is defference between constructor and destructor |
| Both Constructor and Destructor are member functions of the class. Both are made by the language defaultly, and can be override by the programmer. The constructor is being called when a new object of the class is created- it can be used to initiate members, to call functions and what ever is needed when an instance of the class is being made. The destructor is a function that is responsible for avoiding memory leak when deleteting an object. It's important to put a virtual befor constructors of base classes in order to avoid memory leak. |
| |
Back To Question | |