Answered step by step
Verified Expert Solution
Link Copied!

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 car1, car2, car3, and car4:
carType1 car1; // You will need a default constructor
car1.make = "Ford";
car1.setPrice =64456.99// You will use setters for instances that are not initialized by the 5 parameter constructor
CarType1 car2("Ford", "Mustang", "Red", 2022,74599.99); // You will also need a 5 parameter constructor
// Output: 2022 Ford - Mustang, Red($74599.99)
carType2 car3;
carType2 car4("Ford","F150", "Black", 70999.99); // carType2's can only be assigned by constructors
// Output: 2024 Ford - F150, Black($70999.99)
The 2 classes carType1 and carType2 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 carType1 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 set/get functions you will need two constructors (default and 5 parameter). Write a one-line statement in main() to output the corresponding car1 and car2 detail: "2022 Ford - Mustang, Red($74599.99)".
For the carType2 class, create member function printCar() that prints out the corresponding car detail: "2022 Ford - Mustang, Red($74599.99)". 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 4 parameters). All cars of carType2 will have the year set to 2024 by default.
The default construct should be set to "" for strings and 0 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Describe the nature of negative messages.

Answered: 1 week ago