Destructor

Noun · Development

Definitions

  1. A special method called automatically when an object is destroyed or goes out of scope, used to release resources such as memory, file handles, or network connections.

    In plain English: A cleanup function that runs automatically when an object is no longer needed, like a janitor who locks up and turns off the lights when everyone leaves.

    Example: "The destructor closes the database connection so we don't leak handles when the object is garbage collected."

Related Terms