Build a Generic Box Storage Class

Hard Templates & Generic Programming PRO
🔒 Login to Unlock

Problem Statement

Combine concepts! Build a generic `Box` class template that encapsulates a `std::vector items`. Implement `void add(T item)` to push elements, and `void printAll()` to output elements separated by a space. In `main()`, instantiate `Box`, read N, add N strings into the box, and call `printAll()`.

Input Format

Line 1: N. Line 2: N space-separated strings.

Output Format

Print the strings separated by space.

Constraints

1 <= N <= 20

Sample Input

3
Apple Banana Cherry

Sample Output

Apple Banana Cherry

Explanation

This demonstrates wrapping robust STL templates inside your own custom generic class templates for powerful architectural design.

Starter Code

#include <iostream>
#include <vector>
#include <string>

// Build your Box<T> template class here

int main() {
    // Setup Box<std::string>, read inputs, 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