Public Inheritance Mode

Easy Single & Multilevel Inheritance
Solve in Playground →

Problem Statement

Define a `Base` class with a public integer `value`. Define a `Derived` class that publicly inherits from `Base`. In `main()`, instantiate `Derived`, read an integer from standard input, assign it to the inherited `value` attribute, and print “Value: [value]”.

Input Format

A single integer.

Output Format

Print the assigned value.

Constraints

None

Sample Input

42

Sample Output

Value: 42

Explanation

Public inheritance keeps public members of the base class public in the derived class, allowing direct access from outside.

Starter Code

#include <iostream>

class Base {
public:
    // Define public integer value
};

class Derived {
    // Inherit publicly from Base
};

int main() {
    // Instantiate Derived, read input, assign to value, 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