Ambiguity in Function Overloading

Medium Polymorphism & Function Overloading
Solve in Playground →

Problem Statement

Create a `Processor` class with `void process(float val)` and `void process(double val)`. They should print ‘Float: [val]’ and ‘Double: [val]’ respectively. Read a decimal value into a `double` variable. Call the float version by explicitly casting the variable, then call the double version normally.

Input Format

A single decimal number.

Output Format

Print both formatted outputs on separate lines.

Constraints

None

Sample Input

3.14

Sample Output

Float: 3.14
Double: 3.14

Explanation

If we pass a generic decimal constant like 3.14, the compiler defaults to double. Explicit casts resolve the ambiguity to access specific overloaded versions.

Starter Code

#include <iostream>

class Processor {
public:
    // Write overloaded process methods here
};

int main() {
    // Read double input, invoke both overloads explicitly
    return 0;
}

Limits

  • Time Limit: 1s
  • Memory Limit: 256MB

Embedded C Programming

Updated: March 15, 2026
Intermediate

Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used