LearnFrenzy
Sign in Take a free test

Arrays and Vectors · Arrays and Vectors MCQ · Question 15

Does vector::clear() free memory? Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 15 Back to Exercise

After v.clear(), what is true?

  • A size is 0 and the memory is always released
  • B size is 0 but the capacity is normally kept Correct
  • C size is unchanged
  • D The vector is destroyed
Correct Answer: Option B

Keeping the buffer makes refilling cheap. Call shrink_to_fit() if the memory must be returned.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links