Multiple Template Arguments

Medium Templates & Generic Programming
Solve in Playground →

Problem Statement

Create a `Pair` class template holding two private values, `first` of type `T` and `second` of type `U`. Create a constructor and a `display()` method that prints ‘First: [first], Second: [second]’. Read an integer and a string, instantiate `Pair`, and call `display()`.

Input Format

An integer followed by a string.

Output Format

Print the formatted details.

Constraints

String will not contain spaces.

Sample Input

10 Apple

Sample Output

First: 10, Second: Apple

Explanation

Templates can accept multiple type arguments, allowing classes to map diverse data types together flexibly.

Starter Code

#include <iostream>
#include <string>

// Write Pair class template here

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