Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Given the declarations of the instances car 1 , car 2 , car 3 , and car 4 : carType 1 car 1 ; /
Given the declarations of the instances car car car and car:
carType car; You will need a default constructor
carmake "Ford";
carsetPrice You will use setters for instances that are not initialized by the parameter constructor
CarType carFord "Mustang", "Red", ; You will also need a parameter constructor
Output: Ford Mustang, Red$
carType car;
carType carFordF "Black", ; carTypes can only be assigned by constructors
Output: Ford F Black$
The classes carType and carType all declare the variable name, make, color, year, and price. The variable price is not accessible in main and derived classes. The variable year is seen in the derived classes but not in main
For the carType class, use a setter member function to assign the private and protected class values from main Create a return get member functions to output the private and protected member variables. In addition to the setget functions you will need two constructors default and parameter Write a oneline statement in main to output the corresponding car and car detail: Ford Mustang, Red$
For the carType class, create member function printCar that prints out the corresponding car detail: Ford Mustang, Red$ Also use a member functions to implement the assignments and output for all private and protected member variables. You will need two constructors default and parameters All cars of carType will have the year set to by default.
The default construct should be set to for strings and for numbers.
Use the appropriate datatypes to write the class definitions that will allow you to create and output the above instances.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started