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
Which of the following is the Boolean logical operator for OR in C#?
VashaNatasha [74]
This would be &&

Hope this helped
8 0
2 years ago
Read 2 more answers
Who should get the copyright credit for a piece of computer art: the CPU, the software, or the programmer? Explain your reasonin
yulyashka [42]

Answer:

The programmer.

Explanation:

The CPU (central processing unit or simply the processor) is the brain of the computer system, it processes data at a very fast rate depending on it's processing speed. But it only relates to speed of data processing and a link between components of the system.

A software is a program code at executes a task in the system. It a logical and follows an algorithm to solve a given task. Computer systems do not generate  lines of code by itself, but instead, A programmer writes the code to create the software used by the system.

6 0
2 years ago
What is the median of 6, 16, 9, 20, 45, 30, and 32?<br> A. 9<br> B. 16<br> C. 20<br> D. 22
Oksana_A [137]
I believe the answer to your question is going to be C. 20
Hope this helps:)
8 0
2 years ago
What command displays detail information about the OSPF interfaces, including the authentication method?
statuscvo [17]
<span>The answer is Show IP OSPF interface

Hope this helped :)</span>
8 0
3 years ago
Read 2 more answers
Which of the following statements about personality are true? Check all of the boxes that apply.
kupik [55]

Answer:

- personallity is an individual's unique combination of attitudes, behaviors, and characteristics.

-(maybe)Being aware of personality characteristics helps people identify their natural abilities and determine  potential careers.

Explanation:

hope helped

7 0
3 years ago
Other questions:
  • Utilities software and word processing software are both eamples of
    10·1 answer
  • How many bit does four gigabyte has
    8·2 answers
  • One of the advantages of off-the-shelf software is that ________________. a. the software contains important features, thus elim
    13·1 answer
  • You may nest while and do-while loops, but you may not nest for loops<br><br><br><br> True False
    10·1 answer
  • Your wireless network has been breached and it seems as though the attacker has modified a portion of your data that is used wit
    12·1 answer
  • Which of the following actions is an example of "window dressing?" a. Using some of the firm’s cash to reduce long-term debt. b.
    13·1 answer
  • Practice problems on functions. Write C function(s) to carry out the specified tasks. For each problem, also write the suggested
    15·1 answer
  • Which properties would be useful to know to search for a Word document? Check all that apply.
    7·1 answer
  • Please help it’s timed
    5·1 answer
  • Zybook C++ 3.21 answer
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!