Resolving Ambiguity in Multiple Inheritance

Medium Multiple & Virtual Inheritance
Solve in Playground →

Problem Statement

Create base classes `Printer` and `Scanner`, both with a method `start()` printing ‘Printer starting’ and ‘Scanner starting’. Create `Copier` inheriting both. In `main()`, instantiate `Copier` and use the scope resolution operator to call both `start()` methods to resolve ambiguity.

Input Format

None

Output Format

Print both messages.

Constraints

None

Sample Output

Printer starting
Scanner starting

Explanation

When two base classes have a method with the same signature, the derived class must use the scope resolution operator (::) to specify which one to call.

Starter Code

#include <iostream>

class Printer {
public:
    // Write your code here
};

class Scanner {
public:
    // Write your code here
};

class Copier : public Printer, public Scanner {};

int main() {
    Copier c;
    // Resolve ambiguity and call both start() 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