Default Template Arguments

Medium Templates & Generic Programming
Solve in Playground →

Problem Statement

Create a `Storage` class template where `T` defaults to `int`. Include a public attribute `T data`. In `main()`, instantiate the class using just `Storage box;` (which defaults to int). Read an integer from input, assign it to `data`, and print ‘Stored: [data]’.

Input Format

A single integer.

Output Format

Print the formatted stored value.

Constraints

None

Sample Input

42

Sample Output

Stored: 42

Explanation

Default template arguments allow instantiation without specifying the type if the default type is desired.

Starter Code

#include <iostream>

// Write Storage class template with default argument here

int main() {
    // Instantiate using Storage<>, assign data, and print
    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