CJCoding With Joseph

Passing Arguments to Base Constructor

Create a base class Vehicle and a derived class Car.

Vehicle is already written: it stores a protected string brand, has a constructor Vehicle(string b), and a getBrand() const method.

Your job: give Car a constructor Car(string b) that forwards b to the Vehicle base constructor using a member initializer list.

When a Car is built with "Toyota", getBrand() returns "Toyota", so the program prints:
Toyota

Do NOT write a main function.

Expected Output:

Toyota
Topics:
Inheritance
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.