Inheriting from Template Classes

Medium Templates & Generic Programming
Solve in Playground →

Problem Statement

Create a template base class `Base` with a public attribute `T data`. Create a standard (non-template) derived class `DerivedInt` that inherits specifically from `Base`. Read an integer, set `data` using a `DerivedInt` object, and print ‘Data: [data]’.

Input Format

A single integer.

Output Format

Print the formatted data.

Constraints

None

Sample Input

99

Sample Output

Data: 99

Explanation

When inheriting from a class template, the derived class must specify the exact data type to fulfill the base class's template requirement.

Starter Code

#include <iostream>

// Write Base<T> template

// Write DerivedInt inheriting Base<int>

int main() {
    // Read input, instantiate DerivedInt, set 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