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.


How are references initialized in C++?

  1. They can be initialized at any time

  2. They must be initialized to NULL

  3. They must be initialized when created

  4. They don't need to be initialized

The correct answer is: They must be initialized when created

References in C++ must be initialized when they are created. Unlike pointers, which can be initialized at any time and can point to NULL, references must have a valid object to refer to when they are created. If a reference is not initialized, it will result in a compile-time error. Option D is incorrect because references must always be initialized, even if it is to NULL. Option A is also incorrect because references cannot be initialized after they are created. Option B is partially correct in that references must be initialized, but it is not necessary for them to be initialized to NULL.