#include <iostream>
using namespace std;

class Device {
public:
    void showType() {
        cout << "Generic Device\n";
    }
};

// Define class Actuator with private inheritance from Device
class Actuator : private Device {
public:
    // implement showActuator() that calls showType() and then prints "Actuator Device"
    void showActuator() {
        // showType() is accessible here because it was public in Device 
        // and becomes private in Actuator due to private inheritance.
        showType(); 
        cout << "Actuator Device\n";
    }
};

int main() {
    Actuator a;
    a.showActuator();  // calls the public method in Actuator
    
    // a.showType(); // ERROR: showType is now private in Actuator and inaccessible in main
    
    return 0;
}
Upvote
Downvote
Loading...

Input

Expected Output

Generic Device Actuator Device