Question: C++ (Default Constructor, Setter, Getter and Display Function) Modify the following C++ Code so that it uses: A Default Constructor to Initialize the Attributes or

C++ (Default Constructor, Setter, Getter and Display Function)

Modify the following C++ Code so that it uses:

A Default Constructor to Initialize the Attributes or Data Members. A Setter Function to set the value of data members. A Getter Function to display all data members.

and

Creates the Record of 2 cars and display it

#include

using namespace std;

class car

{ public: string Manufacturer; string Model ; int Chassis ; string Color ; float Price ; float Tank ; float TvScreen; int Airbags;

public:

car(string man,string mod,int cha,string col,float pr,float tank,float tv,int air) {

Manufacturer=man; Model=mod; Chassis=cha; Color=col; Price=pr; Tank=tank; TvScreen=tv; Airbags=air; }

void upgrade_Airbags(int bags) { Airbags=bags; }

void display() { cout cout cout cout cout cout cout cout cout cout cout cout cout cout cout } };

int main() { car obj("Ford","Ertiga",5,"grey",45000,78.5,4.5,2);

obj.display(); cout" ";> cout"after> cout obj.upgrade_Airbags(6);

obj.display();

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!