Your task is to define two classes:
- Base class:
Device- Has a public method void
showType() that prints:
Generic Device
- Derived class:
Actuator (inherits privately from Device)- Has a public method void
showActuator() that:- Calls
showType() (accessible inside because of inheritance). - Prints:
Actuator Device
The program will:
- Create an Actuator object.
- Call only
showActuator() — showType() is completely hidden from outside.
Example
Output:
Generic Device
Actuator Device
Why this output?
Because showType() becomes private when inherited, so only the Actuator itself can use it, not even further derived classes.
Question Significance
Demonstrates private inheritance, where base methods become private members in the derived class.