Tuesday, May 13, 2008

Explain what constructors and destructors are and describe what they are used for.

The constructor is the method that initializes a class or structure and is run when a type is first instantiated. It is used to set default values and perform other tasks required by the class. A destructor is the method that is run as the object is being reclaimed by garbage collection. It contains any code that is required for cleanup of the object.

No comments: