#include <iostream>
using namespace std;

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

                class Sensor : public Device {  // Sensor inherits publicly from Device
                public:
                    void printSensor() {
                            cout << "Sensor Device" << endl;
                                }
                                };

                                int main() {
                                    Sensor s;
                                        s.printType();    // Calls base class method
                                            s.printSensor();  // Calls derived class method
                                                return 0;
                                                }
Upvote
Downvote
Loading...

Input

Expected Output

Generic Device Sensor Device