Create a program called question2.cpp that creates a class called Car. Each car has a name (string), a model year, and
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Create a program called question2.cpp that creates a class called Car. Each car has a name (string), a model year, and
Create a program called question2.cpp that creates a classcalled Car. Each car has a name (string), a model year, and a speed. The constructor of the class initializes theclass’s object with the car's name, model year, and speed. There is a function also called void accelerate(floatx), and float getSpeed(). The first one increases the current speed of the car by a value x, and the secondone returns the current speed of the car in km/h.This is a sample usage of the class in main: Car a (“Ford”, 2019, 37.8);a.accelerate(20.4); a.getSpeed();