Construct a class named Car containing these three data members: a double-precis
ID: 3645138 • Letter: C
Question
Construct a class named Car containing these three data members: a double-precision variable named engineSize, a character variable named bodyStyle, and an integer variable named colorCode. The member functions should include a constructor that provides default values of 0 for each numeric data member and an x for each character variable; a display function that prints the engine size, body style, and color code; and an assignment operator that peforms a memberwise assignment between two Car objects for each instance variable.Include the class written from above into a working C++ program that creates and displays two Car objects; the second object is assigned the values of the first object.
Explanation / Answer
#include #include #include using namespace std; class car{ double enginesize; char bodystyle; int colorcode; //Constructor car() { this.enginesize = 0.0; this.bodystyle = 'x'; this.colorcode = 5; } void display() { coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.