Mastering C++: A Comprehensive Quiz Based on 'Thinking in C++'

Disable ads (and more) with a membership for a one time $2.99 payment

Test your C++ skills with our quiz based on Bruce Eckel's 'Thinking in C++'. Dive into object-oriented programming, advanced topics, and fundamentals. Perfect for learners and experts alike. Assess your knowledge and become a C++ master!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


What must be ensured for objects stored in Stash and Stack containers?

  1. They are created on the heap

  2. They have overloaded constructors

  3. They use custom memory management

  4. They are default-constructed

The correct answer is: They are created on the heap

Objects stored in Stash and Stack containers must be created on the heap. Stash containers use dynamic memory allocation in order to store objects and they need to be created on heap in order to be used for dynamic memory allocation. Stack containers are also built to use dynamic memory allocation in last in, first out order. Hence, objects in Stack containers must also be created on the heap. The other options mentioned - B, C and D - are incorrect because those concepts are not directly related to properties of objects stored in Stash and Stack containers. Option B states overloaded constructors as a compiler mechanism in object-oriented programming languages, and not needed specifically for Stash and Stack containers. Option C states custom memory management, which is not a requirement for either Stash or Stack containers. Option D mentions default-constructed objects, which are objects without arguments passed into constructors, and it is not a property of objects