Accessing Overridden Base Methods (Base::method())

Medium Single & Multilevel Inheritance
Solve in Playground →

Problem Statement

Define a `Base` class with a `void log()` method printing “Log Base”. Define a `Derived` class overriding `log()`. Inside the overridden `log()`, first call `Base::log()` using the scope resolution operator, then print “Log Derived”. Instantiate `Derived` and call `log()`.

Input Format

None

Output Format

Print the two messages on separate lines.

Constraints

None

Sample Output

Log Base
Log Derived

Explanation

You can explicitly call an overridden base class method from the derived class by using the scope resolution operator (::).

Starter Code

#include <iostream>

class Base {
public:
    // Define log()
};

class Derived {
    // Inherit Base and override log() calling Base::log() first
};

int main() {
    // Instantiate Derived and call log()
    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