Question 78

In C++, which of the following statements correctly returns the memory from the dynamic array pointer pp to the free store?

  1. Adelete pp;
  2. Bdelete pp [];
  3. Cdelete [] pp;
  4. Ddelete *pp;
Show answerHide answer

Correct answer: (C) delete [] pp;

Explanation

Memory allocated with new[] for an array must be freed with delete [] pp, so that the whole array is released and destructors run for every element.

From DSSSB TGT Computer Science Practice Set 1

This is question 78 of DSSSB TGT Computer Science Practice Set 1. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.