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
Analyze the error in the html code :<br><br> HTML
Andrei [34K]

Answer:

The World Wide Web Consortium provide a simple online tool (https://validator.w3.org/) that automatically check your HTML code and point out any problems/errors your code might have, such as missing closing tags or missing quotes around attributes.

Explanation:

your question is not clear

hope it helps

6 0
3 years ago
Which statement is NOT true:
RSB [31]

Answer:

The correct answer for the given question is   "Machine languages can be used to write programs that can run on any machine."

Explanation:

The machine language consist of binary digit i. e 0 and 1 .Computer can understand only the machine language .The machine language consist of code that is written in bits so it is used  to express algorithms.When any program is compiled the compiler are converted into machine code so the machine language is produced by the compiler .

Machine language cannot used to write a program that run on any machine.

5 0
3 years ago
What is an example of fibre optic cable<br>​
Arte-miy333 [17]

Answer:

printing cable

Explanation:

is a cable used to transfer information from a computer to the printer in packages

5 0
2 years ago
A keyboard shortcut is a key or combination of keys that you press to access a feature or perform a command. ___________________
andrey2020 [161]
I believe that this is true.
Ctrl+F
Ctrl+C
Ctrl+V
These are all keyboard shortcuts.

8 0
3 years ago
1,2,3,4,5,6,7,8,9,10 – Best case - Sorted in ascending order
Pepsi [2]

Using the knowledge in computational language in python it is possible to write a code that from a random number draw creates an order of increasing numbers

<h3>Writting the code in python:</h3>

<em>def shellSort(array, n):</em>

<em>    # Rearrange elements at each n/2, n/4, n/8, ... intervals</em>

<em>    interval = n // 2</em>

<em>    while interval > 0:</em>

<em>        for i in range(interval, n):</em>

<em>            temp = array[i]</em>

<em>            j = i</em>

<em>            while j >= interval and array[j - interval] > temp:</em>

<em>                array[j] = array[j - interval]</em>

<em>                j -= interval</em>

<em>            array[j] = temp</em>

<em>        interval //= 2</em>

<em>data = [10,9,8,7,6,5,4,3,2,1]</em>

<em>size = len(data)</em>

<em>shellSort(data, size)</em>

<em>print('Sorted Array in Ascending Order:')</em>

<em>print(data)</em>

See more about python at brainly.com/question/18502436

#SPJ1

5 0
1 year ago
Other questions:
  • What does the picture indicate on the famous book “Dawn of the century”?​
    10·1 answer
  • A U.S. social security number consists of a string of 9 digits, such as "444422333". Declare a char array named ssn suitable for
    5·1 answer
  • Which is an example of correct HTML?
    10·1 answer
  • Date criteria are automatically enclosed in ____ when entered in a query design.
    11·1 answer
  • Callie Crystal owns and operates one of the most successful local coffee shops in Denver, called The Edgewater Café. Each time a
    5·2 answers
  • Write a method that determines the total number of chars in each string of an array.
    12·1 answer
  • To add a new kind of information into the database you need to add a new table<br> true or false?
    7·2 answers
  • Which of the following statements is FALSE?
    5·1 answer
  • HOW TO DISCONNECT A MONITOR FROM A SYSTEM UNIT
    6·1 answer
  • Array bounds checking should be directly coded into a system rather than assumed.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!