Default Arguments vs. Overloading

Medium Polymorphism & Function Overloading
Solve in Playground →

Problem Statement

Create a `Greeter` class with two overloaded methods: `void greet(std::string name)` and `void greet(std::string name, std::string title)`. The single-arg version prints ‘Hello [name]’. The double-arg version prints ‘Hello [title] [name]’. Read a name and title. Call the single-arg version, then the double-arg version.

Input Format

Two space-separated strings (Name, Title).

Output Format

Print the two greetings on separate lines.

Constraints

None

Sample Input

Smith Dr.

Sample Output

Hello Smith
Hello Dr. Smith

Explanation

If we had used a default argument like `greet(string name, string title="")`, we wouldn't need overloaded methods. Explicit overloading separates exact behaviors based on input.

Starter Code

#include <iostream>
#include <string>

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

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