Question:
constructors and deconstors in c++?
suman A
2009-02-18 04:53:00 UTC
constructors and deconstors in c++?
Three answers:
Germann A
2009-02-18 05:15:34 UTC
http://www.google.co.uk/search?q=c%2B%2B+constructor&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a



The second one is called destructor...

http://www.google.co.uk/search?q=c%2B%2B+destructor&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a
Chris C
2009-02-18 13:30:04 UTC
Neither of these are not required by a class.



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.
Loading...