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
attashe74 [19]
3 years ago
15

Write a copy assignment operator for CarCounter that assigns objToCopy.carCount to the new objects's carCount, then returns *thi

s. Sample output for the given program:
Cars counted: 12
#include
using namespace std;

class CarCounter {
public:
CarCounter();
CarCounter& operator=(const CarCounter& objToCopy);
void SetCarCount(const int setVal) {
carCount = setVal;
}
int GetCarCount() const {
return carCount;
}
private:
int carCount;
};

CarCounter::CarCounter() {
carCount = 0;
return;
}

// FIXME write copy assignment operator

/* Your solution goes here */

int main() {
CarCounter frontParkingLot;
CarCounter backParkingLot;

frontParkingLot.SetCarCount(12);
backParkingLot = frontParkingLot;

cout << "Cars counted: " << backParkingLot.GetCarCount();

return 0;
}
Computers and Technology
1 answer:
Olin [163]3 years ago
5 0

The following cose will be used to copy assignment operator for CarCounter

<u>Explanation:</u>

Complete Program:

#include <iostream>

using namespace std;

class CarCounter

{

public:

CarCounter();

CarCounter& operator=(const CarCounter& objToCopy);

void SetCarCount(const int setVal)

{

 carCount = setVal;

}

int GetCarCount() const

{

 return carCount;

}

private:

int carCount;

};

CarCounter::CarCounter()

{

carCount = 0;

return;

}

// FIXME write copy assignment operator

/* Your solution goes here */

CarCounter& CarCounter::operator=(const CarCounter& objToCopy)

{

if(this != &objToCopy)

 carCount = objToCopy.carCount;

return *this;

}

int main()

{

CarCounter frontParkingLot;

CarCounter backParkingLot;

frontParkingLot.SetCarCount(12);

backParkingLot = frontParkingLot;

cout << "Cars counted: " << backParkingLot.GetCarCount();

cout << endl << endl;

system("pause");

return 0;

}

You might be interested in
Write a function to sum the following series:
Phoenix [80]

Answer:

<u>C program to find the sum of the series( 1/2 + 2/3 + ... + i/i+1)</u>

#include <stdio.h>

double m(int i);//function declaration  

//driver function

int main() {

int i;

printf("Enter number of item in the series-\n");//Taking input from user

scanf("%d",&i);

double a= m(i);//Calling function

printf("sum=%lf",a);

return 0;

}

double m(int i)//Defining function

{

double j,k;

double sum=0;

for(j=1;j<i+1;j++)//Loop for the sum

{

k=j+1;

sum=sum+(j/k);

}

return sum;

}

<u>Output:</u>

Enter number of item in the series-5

sum=3.550000

5 0
2 years ago
Please Help ASAP. Marking Brainliest For Correct Answer.
mezya [45]

Answer: It is not working because it is missing the code needed to turn right.

Sentence :The robot would move forward two squares and would stay stuck there because it can not move forward nor turn left. You would need to add code for the robot to be able to turn right so that the robot can reach the goal

6 0
2 years ago
Nowadays, most online discussion boards are on Web-based forums that provide a variety of user-friendly tools to create and post
Katyanochek1 [597]

Answer:

The correct answer to the following question is option e.) Usenet.

Explanation:

Usenet - it  is a collection of the user-submitted messages or notes on the various subject that posted to the servers on the worldwide network. Each of the subject collection of notes is known as newsgroups. There are thousands of the newsgroups which is possible for us to form the new one.

It works like the decentralized computer network which allows us to download our required files. We can also download and access the binary files along with the text post.

5 0
3 years ago
The following code will create a zombie child process because the child process is terminated and the parent process is busy in
Georgia [21]

Answer:

what on earth

Explanation:

5 0
3 years ago
A storage location in the computer's memory that can hold a piece of data is called:
Zigmanuir [339]

Answer:

b. a variable

Explanation:

A variable holds a specific type of data

3 0
2 years ago
Other questions:
  • Which fingers do you use to type the following letters rtgvf
    11·1 answer
  • Information from the system that is used to make modifications in the input, processing actions, or outputs is referred to as: G
    9·2 answers
  • What is not an option when a user is exporting contacts to share with others?
    10·1 answer
  • What expressions will initialize d with a random value such that all possible values for d are given by the inequality 1.5 ≤ d &
    8·1 answer
  • How can the function anotherFunc2 change the contents of the second element of t?
    5·1 answer
  • Linda is viewing the campaign report in her Google Ads account after successfully implementing conversion tracking tags for her
    7·1 answer
  • A network systems administrator would most likely help with
    13·2 answers
  • A photographer stores digital photographs on her computer. In this case the photographs are considered the data. Each photograph
    6·1 answer
  • Guidewords for the word “serpent” may be
    8·2 answers
  • _____ oversee the work of various types of computer professionals and must be able to communicate with people in technical and n
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!