All submissions

Multiple Inheritance Sensor and Logger

#include <iostream>
using namespace std;

class Sensor {
public:
    // your code here: implement void readValue() to print "Reading sensor value"
    void readValue(void){
        printf("Reading sensor value\n");
    }
};

class Logger {
public:
    // your code here: implement void logData() to print "Logging data"
    void logData(void){
        printf("Logging data\n");
    }
};

// your code here: define class SmartSensor inheriting publicly from Sensor and Logger
// implement process() to call both readValue() and logData()
class SmartSensor : public Sensor, public Logger{

    public: 
        void process(void){
            readValue();
            logData();
        }
};

int main() {
    SmartSensor ss;
    ss.process();
    return 0;
}
Loading...

Input

Expected Output

Reading sensor value Logging data