Your task is to define the following class hierarchy:
show() that prints:Generic Deviceidentify() that prints:Smart DeviceThe program will:
SmartDevice object.show() (inherited from Device).identify() (defined in SmartDevice).Example
Output:
Generic Device
Smart Device
Why this output?
Without virtual inheritance, SmartDevice would have two copies of Device.
By using virtual public, only one shared instance of Device exists.
Question Significance
This problem demonstrates how virtual inheritance solves the diamond problem when multiple paths lead to the same base.
Expected Output
Generic Device Smart Device