えいたんごクイズ

destructor

/dɪˈstrʌktər/
noun

デストラクタ(オブジェクト破棄時はきじ実行じっこうされるメソッド)

解説 Definition

プログラミング言語において、オブジェクトが破棄される時に自動的に実行される特別なメソッド。C++やその他のオブジェクト指向言語で使用される。

A destructor is a special method in object-oriented programming that runs when an object is being destroyed. Its job is usually to release resources such as memory, files, or connections. Usage note: the exact behavior depends on the programming language.

覚え方のコツ Memory Tip

プログラミングでは constructor で作って、destructor で片づける、とセットで覚えるのが最も強いです。construct が「組み立てる」側なら、destructor はその終わり側。destroy に似ていますが、単に壊すというより「オブジェクト終了時の後始末を自動で行う」語だと押さえると混同しにくくなります。C++なら scope を抜けるときに file を閉じる、memory や resource を release する場面と結び付けると定着します。

Remember the pair `constructor` and `destructor`. One creates an object; the other handles the cleanup when the object ends, so `destructor` belongs to the finishing stage, not simple destruction. In C++, connect it with leaving scope, closing files, and releasing resources.

例文

The destructor is called when the object is deleted from memory.

デストラクターはメモリからオブジェクトが削除されるときに呼ばれる。

In C++, you define a destructor to clean up resources.

C++では、デストラクターを定義してリソースをクリーンアップする。

Without a proper destructor, memory leaks can occur.

適切なデストラクターがないとメモリリークが発生する可能性がある。

destructor の類義語・関連語

destructor の語源・成り立ち Etymology

destructorはラテン語destruere「取り壊す」に由来し、de-「離して・逆に」+struere「積み上げる、組み立てる」+-tor「するもの」でできています。直訳すると「組み立てたものをほどく役」で、destroystructureも同根。オブジェクトを終わりに片づけるメソッド名なのが腑に落ちます。

Destructor comes from Latin destruere, meaning "to pull down," with the ending -tor meaning "something that does." Destruere is built from de- and struere, "to build" or "to pile up," so the word originally meant something like undoing what has been built. That is why it fits the modern technical sense of something that cleans up or ends an object; destroy and structure share the same root.

外部辞書で調べる

この単語をシェア

この単語を英単語クイズで覚えよう