- 2069 Chaitra · 2+2 marks
Effect of derivation types on class members
Short answer
Derivation mode (public, protected, private) determines how base members are inherited: public derivation keeps public as public; protected makes both public and protected into protected; private makes them private. Inheritance types: single, multiple, multilevel, hierarchical, hybrid.
How do different types of derivation affect the members of class? Write down the types of inheritance.
Effect of the type of derivation
The derivation mode (public, protected, private) decides how the base class members are seen in the derived class and outside it. Private members of the base are never directly accessible in the derived class in any mode.
| Base member | public derivation | protected derivation | private derivation |
|---|---|---|---|
| public | public | protected | private |
| protected | protected | protected | private |
| private | not accessible | not accessible | not accessible |
- Public: "is-a" relation; the public interface of the base remains public.
- Protected: base public and protected members become protected, usable only in the derived class and its children.
- Private: all accessible base members become private in the derived class (the default for
class).
Example: class D : public B {}; keeps B's public members public in D.
Types of inheritance
- Single - one base, one derived class:
A -> B. - Multiple - a derived class has two or more base classes:
A, B -> C. - Multilevel - a chain:
A -> B -> C. - Hierarchical - several derived classes from one base:
A -> B, A -> C. - Hybrid - a combination of the above (e.g. diamond).
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Access overridden members from derived class · Object Oriented Programming, chapter 6 · asked 2×
- Multipath inheritance problem and solution · Object Oriented Programming, chapter 6 · asked 2×
- Time class: add two objects · Object Oriented Programming, chapter 1
- LandMeasure class and sum function · Object Oriented Programming, chapter 4
- Distance class relational operators · Object Oriented Programming, chapter 5
- Class and function template with syntax · Object Oriented Programming, chapter 9 · asked 4×
- Image charge derivation for Schottky effect · Electrical Engineering Material, chapter 2 · asked 2×
- Quadrilateral speed-time curve on down gradient · Utilization of Electrical Energy, chapter 4
- Video rental shop class diagram · Object Oriented Analysis and Design, chapter 2
- Maximum switching overvoltage derivation · High Voltage Engineering, chapter 3 · asked 2×