LearnFrenzy
Sign in Take a free test

Encapsulation · Encapsulation MCQ · Question 15

What does private inheritance express? Answer, explanation & discussion

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

What relationship does class Stack : private std::vector<int> express?

  • A Stack IS-A vector
  • B "Implemented in terms of": Stack reuses vector's implementation but hides its interface Correct
  • C vector IS-A Stack
  • D Stack HAS-MANY vectors
Correct Answer: Option B

Outside code cannot treat a Stack as a vector or call insert on it; using-declarations can re-expose chosen members. A private member is usually simpler.

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