answer.
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]
2 years ago
9

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

Computers and Technology
1 answer:
ycow [4]2 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
Describe the Say It, Cover It, Resay It method.
bazaltina [42]
You read it aloud to whilst looking at the word, then it when you are confident enough you cover up the word and repeat saying it aloud
7 0
2 years ago
Read 2 more answers
Write a sequence of statements that create a file named "greeting" and write a single line consisting of "Hello, World!" to that
tia_tia [17]

Answer:

The solution code is written in Python 3 as below:

  1. outfile = open("greeting.txt", "w")
  2. outfile.write("Hello World")
  3. outfile.close()

Explanation:

To create a simple text file in Python, we can use Python built-in function, <em>open()</em>. There are two parameters needed for the open() function,

  1. the file name and
  2. a single keyword "w". "w" denote "write". This keyword will tell our program to create a file if the file doesn't exist.

The statement <em>open("greeting.txt", "w")</em> will create a text file named "<em>greeting.txt</em>" (Line 1)

To fill up the content in the greeting.txt, we use <em>write()</em> method. Just include the content string as the argument of the <em>write()</em> method. (Line 2)

At last, we use <em>close() </em>method to close the opened file,<em> outfile</em>. This will release the system resource from the<em> outfile.</em>

4 0
2 years ago
Your friend Margo is considering what type of display to purchase with her new desktop computer and she asks you for advice. You
Oxana [17]

Answer:

d. They do not take up much desk space.

Explanation:

Small foot print means computers do not take up much desk space.

5 0
2 years ago
Write the definition of a function power_to, which receives two parameters. The first is a float and the second is an integer. T
Ber [7]

Answer:

  1.    public static double power_2(double num1, int num2){
  2.        if(num2<0){
  3.            return 0;
  4.        }
  5.        else{
  6.            double returnedVal = Math.pow(num1,num2);
  7.            return returnedVal;
  8.        }
  9.    }

Explanation:

  • This is implemented in Java programming language
  • Line 1 Is the method declaration which indicates that it will return a floating point number (type double) and accepts two parameters, the first a double and the second an int as required by the question
  • Line 2 Uses and if statement to check if the second parameter is negative (less than 0) and returns 0.0 if this is true
  • Lines 5-7 is the else condition that uses java's Math.pow method to raise the num1 to the power num2 and returns the value
3 0
2 years ago
The video clip on driverless cars explained that brain signals from the individual wearing the headset are converted by computer
Olegator [25]
A saftey issue because what is the car malfunctions or red light or police jus drive yo own car
5 0
2 years ago
Read 2 more answers
Other questions:
  • Name an analog quantity other than temperature and sound.
    14·1 answer
  • The X.500 standard defines a protocol for a client application to access an X.500 directory known as which of the following opti
    10·1 answer
  • A device has an IP address of 10.1.10.186 and a subnet mask of 255.255.255.0. What is true about the network on which this devic
    9·1 answer
  • The effectiveness of a(n) _____ process is essential to ensure the success of a data warehouse. Select one: a. visual basic b. e
    15·2 answers
  • A 2-dimensional 3x3 array of ints, has been created and assigned to tictactoe. Write an expression whose value is true if the el
    10·1 answer
  • Assume that the following method header is for a method in class A. public void displayValue(int value) Assume that the followin
    11·1 answer
  • You need to design a data storage scheme for Hayseed Heaven library data system. There are several hundred thousand large data r
    8·1 answer
  • What are some reasons DNS is necessary? Check all that apply. A. It maps local addresses to simple names without editing hosts f
    7·1 answer
  • What are ways to enter a formula in Excel? Check all that apply. Click on the Function Library group and select a function from
    10·2 answers
  • there is a structure called employee that holds information like employee code, name, date of joining. Write a program to create
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!