Mastering C++: A Comprehensive Quiz Based on 'Thinking in C++

Question: 1 / 565

What do you need to do to allow a derived class to use the members of its base class?

Declare them as public in the derived class

Inherit them using the 'protected' keyword

Inherit them using the 'public' keyword

In order for a derived class to use the members of its base class, the 'public' keyword should be used to inherit those members. This allows for the derived class to have access to the public members of the base class without explicitly declaring them again. Option A is incorrect because public members in the base class can already be accessed by derived classes without needing to declare them again. Option B is incorrect because the 'protected' keyword only allows for access by the base class and its derived classes, but not by other classes in the program. Option D is incorrect because copying the members to the derived class would create duplicate code and defeat the purpose of inheritance.

Get further explanation with Examzify DeepDiveBeta

Copy them to the derived class

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy