Ace Your C++ Skills 2025 – Rock the ‘Thinking in C++’ Challenge!

Image Description

Question: 1 / 565

What limitation does a singly-rooted hierarchy, like the one in Smalltalk, impose in C++?

It requires every class to use virtual functions

It increases memory usage significantly

It forces every class to be part of a single inheritance tree

Explanation A singly-rooted hierarchy, like the one in Smalltalk, only allows for single inheritance, meaning that a class can only inherit from one parent class. This limitation forces every class to be part of a single inheritance tree as opposed to allowing for multiple inheritance. This can restrict the flexibility and modularity of a program, as different classes cannot be inherited from multiple sources to add specific functionalities. Therefore, the use of a singly-rooted hierarchy in C++ may not be the best design choice for more complex and diverse programs. Option A is incorrect as virtual functions are not a requirement for a singly-rooted hierarchy. Option B is also incorrect as the limitation does not necessarily increase memory usage, but rather restricts inheritance options. Option D is also incorrect as dynamic memory allocation can still be used in a singly-rooted hierarchy, just with the limitation of only having one parent class.

Get further explanation with Examzify DeepDiveBeta

It prevents the use of dynamic memory allocation

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy