โ Back to Classes
Question 143
Multi-Level Inheritance With Overrides
Multi-Level Inheritance With Overrides
You are given a base class Vehicle with a protected int speed and a virtual function describe().
An intermediate class Car has been partially provided: it inherits from Vehicle and adds a protected int doors member.
Your tasks:
1. Implement the Car constructor (takes speed and doors, calls Vehicle base constructor)
2. Create a class SportsCar that inherits from Car
- Has a private bool turbo member
- Has a constructor taking speed, doors, and turbo
- Overrides describe() to print:
Speed: [speed]
Doors: [doors]
Turbo: [yes/no]
Do NOT include a main function. Your code will be tested automatically.
Expected output:
Speed: 200
Doors: 2
Turbo: yesExpected Output:
Speed: 200 Doors: 2 Turbo: yes
Topics:
ClassesInheritance
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cout, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.