111. Fix Lost Driver Data

In embedded firmware, driver objects often store critical configuration values.
If such objects are passed incorrectly to helper functions, part of the configuration may be lost without any compiler error.

You are given a small driver hierarchy where a helper function currently loses device-specific configuration data.

Your task is to fix the program so that all configuration values are preserved and printed correctly, without changing the driver class design.

Problem Description

The program contains:

  • A base driver class that stores common configuration
  • A derived driver class that stores additional device-specific configuration
  • A helper function that processes driver objects

At present, when a derived driver object is passed to the helper function, only the base configuration is printed, and the derived configuration is lost.

This behavior is incorrect for embedded systems.

Objective

Modify the program so that:

  • No configuration data is lost
  • Both base and derived configuration values are printed
  • All printing happens inside a function
  • The solution is suitable for embedded / firmware code

Rules (Strict)

You must follow all rules below:

  • Do NOT modify any class definitions
  • Do NOT add virtual functions
  • Do NOT use pointers
  • Do NOT use dynamic memory allocation
  • Do NOT change data members
  • You MAY change function parameter types
  • You MAY overload functions
  • Use only standard input and output
  • Output text and order must match exactly

 

Input

Two integers separated by space:

baseValue derivedValue

Program Flow (Mandatory Order)

  1. Read two integers from input
  2. Create a DerivedDriver object
  3. Pass the object to a processing function
  4. Print configuration values inside the function

Output

Print exactly two lines:

Base config <value>
Derived config <value>

 

Example

Input:

10 5

Output:

Base config 10
Derived config 5 

 

Constraints

  • Inheritance must be public
  • The fix must prevent loss of derived configuration
  • No redesign of the class hierarchy
  • No runtime polymorphism (virtual not allowed)
  • Code must remain deterministic and embedded-friendly

 

 

 

Loading...

Input

10 5

Expected Output

Base config 10 Derived config 5