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 is the primary issue with the early examples of Stash and Stack classes with regards to object cleanup?

  1. They use too much static memory

  2. They cannot call delete for the objects they point to

  3. They unnecessarily call the constructor

  4. They are not generic enough

The correct answer is: They cannot call delete for the objects they point to

The primary issue with the early examples of Stash and Stack classes is that they lack the ability to properly clean up objects they point to by not calling delete, leading to memory leaks. This means that the allocated memory for the objects is not being freed, causing potential performance and memory issues. Option A is incorrect because static memory usage may be a concern but it is not the primary issue with the classes. Option C is incorrect since oftentimes calling the constructor is necessary for proper object creation. Option D is incorrect as the mismatch between the type of data stored in the stack and the variable being updated is not the primary issue, although it may lead to potential errors.