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]
4 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]4 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
You can replace a formula with its function so it remains constant. true or false.
kumpel [21]
True/Function. You can replace a formula with its function so it remains constant.
4 0
3 years ago
Lisa is modifying a spreadsheet. Which view enables her to see how her changes will look when she prints the spreadsheet?
emmainna [20.7K]
The page layout view

The page layout view is useful for printing spreadsheets. It lets you review what you print and enables you to get a nice feel of the page when it is printed. All of the functions of the standard view are enabled and a few extra tools like ruler and header and footer fields that help achieve an awesome finish to your page.

 



5 0
4 years ago
Read 2 more answers
Var cookie = "username=mike2009";
Serga [27]

Answer:

creates a cookie with a name of “username” and a value of “mike2009”

Explanation:

This javascript code creates a cookie with the name "username" and it's value is "mike2009".This cookie expires after 1 year.Mentioned in the max-age function.Since max-age function takes arguments in seconds so the it sums up to 1 year.It will be deleted after one year.

4 0
3 years ago
Which option identifies the type of variable recorded in the following chart?
Yuki888 [10]
Age 21 i think ........
7 0
3 years ago
Read 2 more answers
Sara just started using the Internet she would like to be a little more efficient and 3 to 4 sentences give Saras some advice ab
kondor19780726 [428]

Answer:

Explanation:

Efficiency with using the internet is mainly about practice. First, you should focus on making sure that your mouse and keyboard are comfortable devices for you and are positioned in a way that best suits your sitting style. Next would be using a browser that allows extension installing as there are many extension applications that drastically simplify everyday internet tasks such as closing a tab, or copying and pasting some text. Lastly, would be practice. Nobody is efficient when they first start learning to use something new, it takes practice. The more you do something the better you get at it.

8 0
3 years ago
Other questions:
  • Someone help me I don’t know what to do /COMPUTER SCIENCE
    5·1 answer
  • What's is the contribution of technology to the country?
    15·1 answer
  • When evaluating portable CD players, you consider price, the sound quality, and ease of using the controls. These are your _____
    8·2 answers
  • A user logging on, an application server connecting to a database server, an authentication server rejecting a password, or an a
    12·1 answer
  • How to add running head and page number in word?
    5·1 answer
  • What are the primary benefits of relying on systems development standards?
    7·1 answer
  • The NFiPA 704 system uses a numerical value between _____ and _____ to indicate the level of hazard for that particular chemical
    6·2 answers
  • Which type of formatting would you apply to spreadsheet data so that each cell is outlined?
    5·1 answer
  • Your data warehousing project group is debating whether to create a prototype of a data warehouse before its implementation. The
    12·1 answer
  • Why do we need to connect computers"​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!