Late Binding vs. Early Binding

Medium Virtual Functions & Abstract Classes
Solve in Playground →

Problem Statement

Create a `Base` class with a virtual method `show()` printing ‘Base show’ and a normal method `display()` printing ‘Base display’. Create a `Derived` class overriding both to print ‘Derived show’ and ‘Derived display’. Point a `Base` pointer to a `Derived` object. Call `show()` then `display()`.

Input Format

None

Output Format

Print the results on separate lines.

Constraints

None

Sample Output

Derived show
Base display

Explanation

Virtual functions use Late Binding (runtime resolution), calling the derived version. Normal functions use Early Binding (compile-time resolution), calling the base version based on the pointer type.

Starter Code

#include <iostream>

class Base {
public:
    // Implement virtual show and normal display
};

class Derived : public Base {
public:
    // Implement show and display
};

int main() {
    // Create Base pointer to Derived object, call both methods
    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