Build an AmphibiousVehicle Hierarchy

Hard Multiple & Virtual Inheritance PRO
🔒 Login to Unlock

Problem Statement

Combine techniques! Create `LandVehicle` (int tires) and `WaterVehicle` (int propellers) virtually inheriting from a `Vehicle` base. Create `AmphibiousVehicle` inheriting from both. Read tires and propellers, set them via the `AmphibiousVehicle` object, and print them.

Input Format

Two space-separated integers.

Output Format

Print 'Tires: [t]' and 'Propellers: [p]'.

Constraints

None

Sample Input

4 2

Sample Output

Tires: 4
Propellers: 2

Explanation

A complete scenario addressing diamond inheritance correctly using virtual base resolution and multiple data attributes.

Starter Code

#include <iostream>

class Vehicle {};

class LandVehicle {
public:
    int tires;
};

class WaterVehicle {
public:
    int propellers;
};

class AmphibiousVehicle {
    // Setup correct inheritance structure
};

int main() {
    // Read input, instantiate, 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