Multiple choice technology programming languages

When a class uses dynamic memory, what member functions should be provided by the class?

  1. An overloaded assignment operator

  2. The copy constructor

  3. A destructor

  4. All of these options

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Classes using dynamic memory must provide a destructor to free allocated memory and prevent leaks. While copy constructor and assignment operator are also important (Rule of Three), the destructor is essential - it's the only one absolutely required. The question asks 'should be provided' and destructor is the minimum essential.