All submissions

Protected Inheritance

#include<iostream>
using namespace std;

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

class Sensor: protected Device
{
public:
    void showSensor()
    {
        showType();
        cout<<"Sensor Device"<<endl;
    }
};

int main()
{
    Sensor s1;
    s1.showSensor();
}
Loading...

Input

Expected Output

Generic Device Sensor Device