Compile-Time Polymorphism: Function Overloading

Easy Polymorphism & Function Overloading
Solve in Playground →

Problem Statement

Create a `Printer` class with overloaded `print` methods. One method takes an `int` and prints ‘Int: [val]’. Another takes a `std::string` and prints ‘Str: [val]’. In `main()`, read an integer and a string, instantiate `Printer`, and call both methods sequentially.

Input Format

An integer followed by a string.

Output Format

Print the formatted values on separate lines.

Constraints

String will not contain spaces.

Sample Input

42 Hello

Sample Output

Int: 42
Str: Hello

Explanation

Function overloading allows multiple functions to have the same name but different parameter types, determining which to call at compile time.

Starter Code

#include <iostream>
#include <string>

class Printer {
public:
    // Write your overloaded print methods here
};

int main() {
    // Read input and call methods
    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