Question: Define a constructor as indicated. Sample output for below program: Year: 0, VIN: -1 Year: 2009, VIN: 444555666 //main.cpp #include using namespace std; class CarRecord

Define a constructor as indicated. Sample output for below program:

Year: 0, VIN: -1

Year: 2009, VIN: 444555666

//main.cpp

#include

using namespace std;

class CarRecord {

public:

voidSetYearMade(int originalYear);

voidSetVehicleIdNum(int vehIdNum);

voidPrint() const;

CarRecord();

private:

intyearMade;

intvehicleIdNum;

};

// FIXME: Write constructor, initialize year to 0, vehicle ID num to -1.

/* Your solution goes here*/

void CarRecord::SetYearMade(int originalYear) {

yearMade = originalYear;

}

void CarRecord::SetVehicleIdNum(int vehIdNum) {

vehicleIdNum = vehIdNum;

}

void CarRecord::Print() const {

cout << "Year: " << yearMade << ", VIN: " << vehicleIdNum << endl;

}

int main() {

CarRecord familyCar;

familyCar.Print();

familyCar.SetYearMade(2009);

familyCar.SetVehicleIdNum(444555666);

familyCar.Print();

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!