A destructor is a special member function that is called automatically when an object is destroyed or goes out of scope. It performs cleanup actions like freeing memory allocated to the object. Destructors are defined with a tilde symbol preceding the class name and they take no arguments and return no value. They are mainly used to delete dynamically allocated memory for an object and its members before the object is destroyed.