#include <iostream> using namespace std; class Device { // Base class public: void printType() { cout << "Generic Device" << endl; } }; class Sensor : public Device { // Sensor inherits from Device public: void printSensor() { cout << "Sensor Device" << endl; } }; int main() { Sensor s; s.printType(); // inherited from Device s.printSensor(); // own method return 0; }
Test Cases
Test Results
Input
Expected Output
Generic Device Sensor Device