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
umka2103 [35]
4 years ago
9

Write a destructor for the CarCounter class that outputs the following. End with newline.

Computers and Technology
1 answer:
ycow [4]4 years ago
7 0

Answer:

Following are the code to this question:

CarCounter::~CarCounter()//Defining destructor CarCounter

{

cout << "Destroying CarCounter\n";//print message Destroying CarCounter

}

Explanation:

Following are the full program to this question:

#include <iostream>//Defining header file

using namespace std;

class CarCounter //Defining class CarCounter

{

public:

CarCounter();//Defining constructor CarCounter

~CarCounter();//Defining destructor CarCounter

private:

int carCount;//Defining integer variable carCount

};

CarCounter::CarCounter()//declaring constructor  

{

carCount = 0;//assign value in carCount variable

return;//using return keyword

}

CarCounter::~CarCounter()//Defining destructor CarCounter

{

cout << "Destroying CarCounter\n";//print message Destroying CarCounter

}

int main() //Defining main method

{

CarCounter* parkingLot = new CarCounter();//Defining class object parkingLot

delete parkingLot;//

return 0;

}

  • In the given C++ language code, a class "CarCounter" is defined, and inside the class, a "constructor, Destructors, and an integer variable" is defined.  
  • Outside the class, the scope resolution operator is used to define the constructor and assign value "0" in the integer variable.  
  • In the above-given code, the scope resolution operator, to define destructor and inside this cout function is used, which prints a message.  
  • In the main method, the class object is created, which automatically calls its class constructor and destructors.  
You might be interested in
The macro command is available on the ___ tab<br> Home<br> Insert<br> View<br> Design
nataly862011 [7]

      Answer                     : Insert tab                                              

5 0
3 years ago
Read 2 more answers
Which of these is most likely to contribute to the long term of a local ecosystem?
maria [59]
I would help but you didn’t say what these is
8 0
2 years ago
Consider the following 3-PARTITION problem. Given integers a1; : : : ; an, we want to determine whether it is possible to partit
ZanzabumX [31]

Answer:

Explanation:

Find attach the solution

6 0
3 years ago
Ask the user for a total food bill and then find the new total after 6% tax and a tip of the users choice (15, 18, 20%) in pytho
chubhunter [2.5K]

Answer:

#here is code in python.

# read the food bill

tot_bill=float(input("Please enter the food bill:"))

# tax on food

tax=0.06

#choice for tip by user

choice=int(input("enter your choice for tip:(1 for 15%, 2 for 18% and 3 for 20% :)"))

// calculate the total food bill

if choice==1:

   tot_food_bill=tot_bill+tot_bill*tax+tot_bill*(.15)

elif choice==2:

   tot_food_bill=tot_bill+tot_bill*tax+tot_bill*(.18)

elif choice==3:

   tot_food_bill=tot_bill+tot_bill*tax+tot_bill*(.2)

else:

   print("invalid choice:")

#print the total food bill

print("total food bill is ",tot_food_bill)    

Explanation:

Read the food bill from user and assign it to variable "tot_bill".Initialize the tax=0.06 (i.e. 6%) on the bill.Then ask user to give his choice for tip. if the choice is 1 then tip will be 15%, if 2 then 18% and if choice is 3 Then tip will be 20% of the bill.Calculate the total food bill and assign it to variable "tot_food_bill".

Output:

Please enter the food bill:100                                                                                                                                

enter your choice for tip:(1 for 15%, 2 for 18% and 3 for 20% :)2                                                                                            

total food bill is  124.0

3 0
3 years ago
Nims is applicable to all stakeholders with incident related responsibilities. True or False
QveST [7]

Answer:

True

Explanation:

National Incident Management System (NIMS) is intended to be used by all individual regardless of there positions. it is aimed with the responsibility of enrolling and issuing Nigerians with national identity cards regardless of the position,degree, or family background.

6 0
3 years ago
Read 2 more answers
Other questions:
  • On the Internet, you can use a(n)______to look for information on any topic, such as books, movies, scholarly articles, news, an
    6·2 answers
  • Cpu, ram, rom, and other electronic components are mounted on a board, which is called the
    15·1 answer
  • What is the keyboard shortcut used to paste previously copied text?
    15·2 answers
  • 5.19 LAB: Countdown until matching digits Write a program that takes in an integer in the range 20-98 as input. The output is a
    14·1 answer
  • The amount of money you can charge to a credit card is called?
    5·2 answers
  • Assume the existence of an UNSORTED ARRAY of n characters. You are to trace the CS111Sort algorithm (as described here) to reord
    14·1 answer
  • Fill up the blank:- The picture that graphically represents the items you use in Windows is called a/an .......
    5·1 answer
  • 1.
    13·1 answer
  • Cuando se introduce una fórmula en una celda primero que hay que introducir es
    13·1 answer
  • What are the positive impact of computer in society
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!