Recall & Review
beginner
What is a base class in C++?A base class is a class that provides properties and behaviors (methods) which can be inherited by other classes called derived classes.Click to reveal answer
beginner
What is a derived class?
A derived class is a class that inherits properties and behaviors from a base class and can add its own features or modify existing ones.Click to reveal answer
beginner
How do you declare a derived class from a base class in C++?Use the syntax: <br> <code>class DerivedClass : access_specifier BaseClass { ... };</code> <br> where <code>access_specifier</code> is usually <code>public</code>.Click to reveal answer
intermediate
What happens if a derived class does not define a constructor?The derived class automatically calls the base class's default constructor to initialize the base part of the object.Click to reveal answer
intermediate
Can a derived class access private members of its base class directly?No, private members of a base class are not accessible directly by derived classes. They can be accessed through public or protected methods of the base class.Click to reveal answer
Which keyword is used to inherit a class in C++?
✗ Incorrect
In C++, inheritance is declared using a colon ':' after the derived class name.
If class B inherits publicly from class A, which members of A are accessible in B?
✗ Incorrect
Public inheritance allows derived class to access public and protected members of the base class.
What is the default access specifier for inheritance in C++ classes?
✗ Incorrect
If no access specifier is given, inheritance is private by default in C++ classes.
Which of these is true about constructors in derived classes?
✗ Incorrect
If a derived class constructor does not specify a base constructor, the base class's default constructor is called automatically.
Can a derived class override a base class method?
✗ Incorrect
In C++, a derived class can override a base class method if it is declared virtual in the base class.
Explain how inheritance works between a base class and a derived class in C++.
Think about how the derived class gets features from the base class.
You got /5 concepts.
Describe the role of constructors in base and derived classes during object creation.
Consider which constructor runs first and how the base part is initialized.
You got /5 concepts.