LearnFrenzy
Sign in Take a free test

Abstract Classes and Interfaces · Abstract Class MCQ · Question 8

Must a pure virtual destructor be defined? Answer, explanation & discussion

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

A class declares virtual ~Base() = 0;. Must Base::~Base() be defined?

  • A No, pure functions never have bodies
  • B Yes – every derived destructor calls it, so it must be defined or linking fails Correct
  • C Only if Base has data
  • D Only in debug builds
Correct Answer: Option B

Destructors run up the whole hierarchy, so the base one always executes.

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