1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
makkiz [27]
3 years ago
7

Create a class Car, which contains Three data members i.e. carName (of string type), ignition (of bool type), and currentSpeed (

of integer type)
 A no-argument constructor to initialize all data members with default values
 A parameterized constructor to initialize all data members with user-defined values
 Three setter functions to set values for all data members individually
 Three getter function to get value of all data members individually
 A member function setSpeed( ) // takes integer argument for setting speed
Derive a class named Convertible that contains
 A data member top (of Boolean type)
 A no-argument constructor to assign default value as “false” to top
 A four argument constructor to assign values to all data-members i.e. carName, ignition, currentSpeed and top.
 A setter to set the top data member up
 A function named show() that displays all data member values of invoking object
Write a main() function that instantiates objects of Convertible class and test the functionality of all its member functions.
Computers and Technology
1 answer:
olasank [31]3 years ago
4 0

Answer:

Copy paste it.

Explanation:

#include <iostream>

#include <string>

using namespace std;

//Create a class Car, which contains • Three data members i.e. carName (of string type), ignition (of bool type), and //currentSpeed (of integer type)

class Car

{

public:

string carName;

bool ignition;

int currentSpeed;

//A no-argument constructor to initialize all data members with default values

//default value of string is "",bool is false,int is 0

Car()

{

carName="";

ignition=false;

currentSpeed=0;

}

//A parameterized constructor to initialize all data members with user-defined values

Car(string name,bool i,int speed)

{

carName=name;

ignition=i;

currentSpeed=speed;

}

//Three setter functions to set values for all data members individually

// Three getter function to get value of all data members individually

void setCarName(string s)

{

carName=s;

}

void setIgnition(bool ig)

{

ignition=ig;

}

void setCurrentSpeed(int speed)

{

currentSpeed=speed;

}

string getCarName()

{

return carName;

}

bool getIgnition()

{

return ignition;

}

int getCurrentSpeed()

{

return currentSpeed;

}

//A member function setSpeed( ) // takes integer argument for setting speed

void setSpeed(int sp1)

{

currentSpeed=sp1;

}

};

//Derive a class named Convertible

class Convertible:public Car

{

//A data member top (of Boolean type)

public:

bool top;

public:

//A no-argument constructor to assign default value as “false” to top

Convertible()

{

top=false;

}

//A four argument constructor to assign values to all data-members i.e. carName, ignition,

//currentSpeed and top.

Convertible(string n,bool i,int s,bool t):Car(n,i,s)

{

carName=n;

ignition=i;

currentSpeed=s;

top=t;

}

// A setter to set the top data member up

void setTop(bool t)

{

top=t;

}

//A function named show() that displays all data member values of invoking object

void show()

{

cout<<"Car name is:"<<carName<<endl;

cout<<"Ignition is: "<<ignition<<endl;

cout<<"Current Speed is :"<<currentSpeed<<endl;

cout<<"Top is:"<<top<<endl;

}

};

//main function

int main()

{

//creating object for Convertible class

Convertible c1("Audi",true,100,true);

c1.show();

c1.setCarName("Benz");

c1.setIgnition(true);

c1.setCurrentSpeed(80);

c1.setTop(true);

c1.show();

cout<<"Car Name is: "<<c1.getCarName()<<endl;

cout<<"Ignition is:"<<c1.getIgnition()<<endl;

cout<<"Current Speed is:"<<c1.getCurrentSpeed()<<endl;

return 0;

}

You might be interested in
Assume you're using a three button mouse. to access shortcut menus, you would
Likurg_2 [28]
<span>Normally you would click the right hand/secondary mouse button but you may configure any of the buttons to work within the Keyboard and Mouse section of System Preferences.
Hope this helps:)</span>
6 0
3 years ago
Read 2 more answers
I / a / caught / when / was / on / disease / holiday / I​
statuscvo [17]

Answer:

Ig it'd be - I caught a disease when i was on a holiday.

4 0
3 years ago
Read 2 more answers
What an underlined word or phrase represents? (HTML AND CSS), has to be 9 letters long. kinda urgent
xz_007 [3.2K]

Answer:

hyperlink

Explanation:

Hyperlinks render as underlined by default, so that's my guess.

7 0
3 years ago
A retail store stocks two types of shirts A and B. These are packed in attractive cardboard boxes. During a week the store can s
antiseptic1488 [7]
300 of A and 300 of b
7 0
2 years ago
Long distances are usually measured in kilometers.<br> T or F?
timama [110]
Depending where you are in the world it is true and false
7 0
3 years ago
Other questions:
  • HELP! Identify the parts of the table. <br>A) Primary Key<br>B) Field<br>C) Record<br>D) Table<br>​
    15·2 answers
  • Which of these is not one of the main parts of an email?
    10·2 answers
  • i see tabs named mowed and Ramsey i tried shredding them and deleting them and ending all the processes but they start duplicati
    13·1 answer
  • Samuel is working on decimal and binary conversion for his college project. He is using the binary number 111011 and wants to ex
    10·2 answers
  • #Electrical Engineering
    13·1 answer
  • You're a ticket agent for a commercial airline and responsible for checking the identification for each passenger before issuing
    13·1 answer
  • Someone plz answer
    8·1 answer
  • Brendan needs to edit all the slides in a presentation by adding a company logo and a header and footer. Which is
    13·2 answers
  • What are the pieces of information that describe the appearance of a cells content
    6·1 answer
  • Given the following declaration, what is the value of b[ 1 ][ 0 ]? int b[ 2 ][ 2 ] = { { 1 }, { 3 , 4 } };
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!