All submissions

Object Accessing Inherited Variables

#include <iostream>
using namespace std;

class Device {
public:
    int id;
};

class Sensor : public Device {
public:
    int value;
    Sensor(int id,int value)
    {
        cout<<"Device ID: "<<id<<", Sensor Value: "<<value;
    }
};

int main() {
    Sensor s(101,75);
    return 0;
}
Loading...

Input

Expected Output

Device ID: 101, Sensor Value: 75