Recall & Review
beginner
What are the three main access specifiers in C++?
The three main access specifiers in C++ are <strong>public</strong>, <strong>private</strong>, and <strong>protected</strong>. They control the visibility of class members.Click to reveal answer
beginner
What does the
private access specifier do?Members declared
private can only be accessed within the same class. They are hidden from outside code and derived classes.Click to reveal answer
intermediate
How does
protected differ from private?<code>protected</code> members are like <code>private</code> but can also be accessed by derived (child) classes, not just the class itself.Click to reveal answer
beginner
What is the default access specifier for class members in C++?By default, members of a
class are private if no access specifier is given.Click to reveal answer
beginner
What is the default access specifier for struct members in C++?
By default, members of a
struct are public if no access specifier is given.Click to reveal answer
Which access specifier allows members to be accessed from anywhere?
✗ Incorrect
public members can be accessed from any part of the program.
If no access specifier is given in a class, what is the default?
✗ Incorrect
Class members are private by default.
Which access specifier allows derived classes to access members but hides them from outside?
✗ Incorrect
protected members are accessible in derived classes but not outside.
What is the default access specifier for members of a struct?
✗ Incorrect
Struct members are public by default.
Can private members be accessed directly by derived classes?
✗ Incorrect
Private members are not accessible by derived classes directly.
Explain the difference between public, private, and protected access specifiers in C++.
Think about who can see or use the class members.
You got /3 concepts.
What are the default access levels for class and struct members in C++?
Remember the difference between class and struct.
You got /2 concepts.