題組內容

1. (20%) Answer the following questions briefly.

(a) For a class with a class name as T. What is the name of its destructor function? (5%)

詳解 (共 1 筆)

詳解 提供者:hchungw
In C++, the destructor for a class named T would be named ~T. Destructors are special member functions that are called when an object of that class is destroyed. They serve the purpose of freeing resources, closing files, or releasing memory that the object may have acquired during its lifetime. The syntax for a destructor is similar to that of a constructor, but with a tilde (~) prefixing the class name.