Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is C++ Consider the definition of the following class: Give the line number

ID: 3665911 • Letter: T

Question

This is C++

Consider the definition of the following class: Give the line number containing the constructor that is executed in each of the following declarations: Write the definition of the constructor in line 4 so that the maker and the model initialize to "" and the noOfDoors and mpg initialize to 0 and the price initializes to 0.00. Write the definition of the constructor in line 5 so that the instance variables are initialized according to the parameters. Write the definition of the constructor in line 8 so that mpg and price initialize to 0 and 0.00 respectively and the other variables initialize to the appropriate parameters.

Explanation / Answer

a)

i)CarType newcar;

calls the default constructor in line no:4

ii)CarType oldcar(“chrysler”,”Impala”);

calls the CarType (String,String) constructor in line number:6

iii) CarType tempcar(4,28,32784.98);

calls the tempcar (int,int,double) constructor in line number:7

b)constructor def line4

CarType(void)

{

maker=””;

model=””;

noofDoors=0;

mpg=0;

price=0.00;

}

c) constructor def line5 with appropriate initialized variables

CarType(String,String,int,int,double)

{

maker=” chrysler”;

model=” Impala”;

noofDoors=4;

mpg=5;

price=534000.00;

}

d) constructor def line8

CarType(String,String,int)

{

maker=” chrysler”;

model=” Impala”;

noofDoors=4;

mpg=0;

price=0.00;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote