Constructors: Used to initialize a class, including allocating memory or opening files (i.e. log files) if necessary, and setting default values for member variables. There can be zero (0) to many constructors for a class.
Destructors: Used to uninitialize a class, which includes deallocating memory as necessary, closing files that may have been opened by the class, etc. There can be only one deconstructor.
tbshmkr
2009-02-18 13:17:52 UTC
No.
=
Constructors and deconstructors are in c++.
=
The main use of constructors is to initialize objects.
The main use of destructors is to release dynamic allocated memory.
ⓘ
This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.