Create an overloaded constructor for the class


Discuss the below:

Write the statements to create an overloaded constructor for the class named Car. The constructors should support 0, 1, or 2 arguments. The first argument will denote the engine size and contain an Integer. The default value is 360. The second argument will denote the color and should have a type of Automobile.Color. The default value is the enumeration White. Declare constants named cintDefaultEngineSize and ccolDefaultColor to store the default values. If no arguments are supplied, then use the default value. If one argument is supplied to the constructor, then assume that the argument is defining the engine size. If two arguments are supplied to the constructor, then assume that the first argument contains the engine size and the second contains the color. For each of the constructors, store the default or specified arguments in the hidden variables named mintEngineSize and mcolDefaultColor.

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Create an overloaded constructor for the class
Reference No:- TGS01933206

Now Priced at $20 (50% Discount)

Recommended (94%)

Rated (4.6/5)