Template Specialization

Hard Templates & Generic Programming
Solve in Playground →

Problem Statement

Create a `Printer` template with a method `print(T val)` that prints ‘Generic: [val]’. Create a full template specialization specifically for `char` that overrides the logic to print ‘Character: [val]’. Read an integer and a character from input, use `Printer` for the integer, then `Printer` for the character.

Input Format

An integer followed by a space and a character.

Output Format

Print the outputs on separate lines.

Constraints

None

Sample Input

100 Z

Sample Output

Generic: 100
Character: Z

Explanation

Template specialization allows you to define distinct, specific behavior for certain data types while retaining generic behavior for everything else.

Starter Code

#include <iostream>

// Define generic Printer<T> here

// Define specialized Printer<char> here

int main() {
    // Read input and use both printers
    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