#include <iostream>
using namespace std;

class Device {
public:
    // In ra loại thiết bị chung
    void printType() {
        cout << "Generic Device" << endl;
    }
};

// Sensor kế thừa từ Device
class Sensor : public Device {
public:
    // In ra loại thiết bị cụ thể
    void printSensor() {
        cout << "Sensor Device" << endl;
    }
};

int main() {
    Sensor s;
    s.printType();    // Gọi hàm kế thừa từ Device
    s.printSensor();  // Gọi hàm của Sensor
    return 0;
}
Upvote
Downvote
Loading...

Input

Expected Output

Generic Device Sensor Device