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 operator is used to select elements within an instance of a structure?

  1. ->

  2. .

  3. ::

  4. []

The correct answer is: .

The dot operator, denoted by a period, is used to access elements within a structure. This operator is the standard way of performing member selection and can be applied to any structure instance. The other options, such as the arrow operator (->), scope resolution operator (:), or square brackets ([]) are used for different purposes and may not work with all types of structures. For example, the arrow operator is used for accessing members of a pointer to a struct, while the scope resolution operator is used for accessing members of a namespace in C++. The square brackets are typically used for indexing elements in a data structure like arrays or vectors. Therefore, these options are incorrect as they are not specific to selecting elements within a structure instance.