122. Compile-Time Overload Resolution

You are given an incomplete firmware diagnostic logging API.

The logging function is intended to support multiple data types using the same function name, relying on compile-time resolution to select the correct implementation.

Your task is to extend the API using function overloading so that:

  • The compiler resolves the correct function call at compile time
  • No runtime conditionals (if, switch) are used
  • The function name remains the same for all supported types

Input / Program Flow:

The firmware diagnostic logic logs values in different formats depending on the data type:

  • When an integer value is logged, it must be printed as a raw count
  • When a floating-point value is logged, it must be printed as a scaled value

Both operations must use the same function name, and the compiler must decide which function to invoke based only on the argument type.

Output:

The program must print exactly:

int=10
float=2.50 

Constraints:

  • No runtime conditionals (if, switch)
  • No virtual functions
  • No inheritance
  • No heap allocation
  • No STL containers
  • Overload resolution must happen at compile time
  • Return type must NOT be used to differentiate overloads

 

 

 

Loading...

Input

Expected Output

int=10 float=2.50