O
AI-generated image

destructor

/dɪˈstrʌktər/ noun · British & US
Valid in UK
Share WhatsApp

What does destructor mean?

A destructor is, most broadly, a person or thing that destroys. In contemporary usage, however, the word belongs chiefly to the world of computer programming: in object-oriented languages such as C++, a destructor is a special member function that runs automatically when an object's lifetime ends, releasing memory, closing files, and performing any other cleanup the programmer specifies. Destructors are the counterpart of constructors, which set objects up when they are created, and together they govern how software manages its resources reliably. Outside computing, the word appears rarely as a synonym for 'destroyer', and in older British English a 'refuse destructor' was a furnace for burning municipal waste — an early ancestor of the modern incinerator. Derived from Latin destruo, 'to pull down or destroy', destructor carries connotations of finality and teardown, making it apt both for demolition in the physical world and for the disciplined dismantling of objects in code.

noun

In object-oriented programming, a special method that is invoked automatically when an object is destroyed, used to release resources such as memory, files, or network connections.

Example

"The destructor frees the dynamically allocated buffer when the object goes out of scope."

Most strongly associated with C++, where destructors are deterministic and can be virtual; other languages offer similar mechanisms under different names.

noun

A person or thing that destroys something.

Example

"Fire proved to be the great destructor of the ancient library's scrolls."

Somewhat formal; 'destroyer' is the usual everyday choice.

noun

Chiefly British, historical: a furnace for destroying refuse; an early incinerator.

Example

"The borough built a new destructor to burn the town's household waste."

Plural destructors

Regular plural, formed with -s.

Example

"Well-written classes define their own destructors to manage cleanup."

Did you know?

In C++, the humble tilde (~) marks the destructor — so ~Object() literally reads as 'not-object', the moment an object ceases to be.

Reviewed by Deb Chak, Editor. AI-assisted content curated by RJS Tech Solutions LLP.

Etymology of destructor

Destructor comes from Latin destruo ('to tear down, destroy'), formed from de- ('down, away') plus struo ('to pile up, build') — literally the undoing of building. It passed into English via post-classical Latin and Old French, with the agent-noun sense established by around the seventeenth century, while the refuse-furnace sense arose in nineteenth-century Britain. Its cognates include destruction, destructive, and, through the shared root struere, words such as structure, construct, and instruct.

How destructor is actually used

The programming sense dominates modern usage, particularly among C++ developers, and is technical rather than general vocabulary. The older British sense referring to refuse-burning furnaces is now largely historical. As a general noun meaning 'one who destroys', 'destroyer' is far more common in ordinary English.

Easily confused with destructor

constructor

A constructor initializes an object and runs when it is created, whereas a destructor cleans up after an object and runs just before it is destroyed.

What's another word for destructor?

Words and phrases paired with destructor

default destructorvirtual destructorcall a destructorclass destructor

What's the opposite of destructor?

Rhymes with destructor