Hybrid Inheritance

Medium Multiple & Virtual Inheritance
Solve in Playground →

Problem Statement

Combine multilevel and multiple inheritance. `Animal` -> `Mammal`. Create `WingedAnimal`. Create `Bat` inheriting from both `Mammal` and `WingedAnimal`. Inside `main()`, invoke a method `eat()` from `Animal` and `fly()` from `WingedAnimal` using a `Bat` object. Print ‘Eating’ and ‘Flying’.

Input Format

None

Output Format

Print the method outputs.

Constraints

None

Sample Output

Eating
Flying

Explanation

Hybrid inheritance mixes two or more types of inheritance. Here, Bat receives traits from a multilevel chain and an independent base class.

Starter Code

#include <iostream>

class Animal {
    // Implement eat()
};

class Mammal : public Animal {};

class WingedAnimal {
    // Implement fly()
};

class Bat {
    // Inherit Mammal and WingedAnimal
};

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