Build a Vehicle -> Car -> SportsCar Hierarchy

Hard Single & Multilevel Inheritance PRO
🔒 Login to Unlock

Problem Statement

Construct a hierarchy where `Vehicle` has `int speed`, `Car` inherits `Vehicle` and adds `int doors`, and `SportsCar` inherits `Car` and adds `int boost`. Use parameterized constructors to pass data up the chain (`Car(s, d) : Vehicle(s)`). Read 3 integers (speed, doors, boost), instantiate `SportsCar`, and print them each on a new line: “Speed: [s]”, “Doors: [d]”, “Boost: [b]”.

Input Format

Three space-separated integers.

Output Format

Print the properties of the sports car.

Constraints

None

Sample Input

200 2 50

Sample Output

Speed: 200
Doors: 2
Boost: 50

Explanation

Constructor initialization chains pass arguments up the inheritance hierarchy to initialize base class attributes.

Starter Code

#include <iostream>

class Vehicle {
public:
    // Define speed and constructor
};

class Car {
public:
    // Inherit Vehicle, define doors and constructor
};

class SportsCar {
public:
    // Inherit Car, define boost and constructor
};

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