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.


Which of the following is a valid declaration for a destructor in a class named 'Item'?

  1. void ~Item();

  2. Item();

  3. ~Item();

  4. void Item();

The correct answer is: ~Item();

A destructor is a function that is called when an object is destroyed. It is denoted by the '~' symbol followed by the class name. Option A is incorrect because the return type should not be specified for a destructor. Option B is incorrect because it is not a valid destructor syntax. Option D is incorrect because it is not a destructor declaration. Hence, the correct option is C.