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 happens if you pass a void pointer to delete?

  1. Destructor is called

  2. Object is not correctly deleted

  3. Memory leak occurs

  4. Constructor is called

The correct answer is: Memory leak occurs

If a void pointer is passed to delete, it will cause a memory leak because delete does not know how much memory to deallocate for the object it points to. This can lead to memory fragmentation and other issues, since the memory will not be reclaimed properly. Passing a void pointer to delete can also cause undefined behavior, as there is no valid object to be deleted.