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!

Practice this question and more.


How can you access a public static class member?

  1. Using the dot or arrow syntax with an instance or the class name and scope resolution operator

  2. With a special 'static' keyword before the function call

  3. By creating a special static object

  4. You cannot access static members directly

The correct answer is: Using the dot or arrow syntax with an instance or the class name and scope resolution operator

A static class member can be accessed through dot or arrow syntax with either an instance or the class name followed by the scope resolution operator. This means that option A is the correct answer. Option B refers to a static keyword before the function call, but this is not necessary for accessing a static member. Option C refers to creating a special static object, which is not necessary to access a static class member. Option D states that you cannot access static members directly, but this is not true as they can be accessed through the methods described in option A.