← Back to Inheritance
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 functiondescribe(). 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 - Overridesdescribe()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: yes
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
ClassesInheritance
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · 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.