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
Since all Java data types (numbers, strings, etc) can be represented as strings, the _______ format specifier can receive any ty
astra-53 [7]

In Java programming, the <u>%s</u> format specifier can receive any type of Java data.

<h3>The kinds of data type.</h3>

In Computer programming, there are five recognized data types and these include:

  • Integer type (int).
  • Character type (char).
  • Floating point type (float).
  • Boolean (bool)
  • String (str)

<h3>What is a string?</h3>

A string is a data type which is typically used for data values that comprises ordered sequences of characters.

In Java programming, strings can be used to represent all Java data types such as numbers, Boolean, strings, etc. Also, the <u>%s</u> format specifier can be used by a programmer or software developer to receive any type of Java data.

Read more on a string here: brainly.com/question/25619349

5 0
2 years ago
Justify the statement "The same job title can have different job roles and different qualification criteria in different organiz
Colt1911 [192]

Answer:

anng elsi

Explanation:

3 0
3 years ago
Which statement is true about laptops? Laptops use fewer components than desktops use. Most of the internal components that are
elena-14-01-66 [18.8K]

Answer:

Option 2 is correct.

Explanation:

Option 2 is correct because most of the components used in laptop is far different from Desktops. They are not able to fix in desktops. They are designed specially for laptops.

8 0
3 years ago
Read 2 more answers
Still giving out the brainly thing :)<br> just answer its as simple as that and you get points :)
solong [7]

Answer:

The answer to that my friend, Is 0 :D

Explanation:

7 0
3 years ago
Read 2 more answers
How will you find and replace particular text in a document​
blsea [12.9K]

Answer:

Find and replace text

Go to Home > Replace or press Ctrl+H.

Enter the word or phrase you want to locate in the Find box.

Enter your new text in the Replace box.

Select Find Next until you come to the word you want to update.

Choose Replace. To update all instances at once, choose Replace All.

Explanation:

6 0
3 years ago
Other questions:
  • An information- and communication-based electronic exchange environment mostly occupied by sophisticated computer and telecommun
    13·1 answer
  • Anti-lock braking systems can significantly.... a. impede your braking stability. B. improve your braking stability. C. improve
    5·1 answer
  • Draw the hierarchy chart and then plan the logic for a program that calculates a person’s body mass index (BMI).
    11·1 answer
  • 1000base-t is a standard for achieving throughputs ____ times faster than fast ethernet over copper cable.
    8·1 answer
  • In the value chain concept, upgrading IT is considered what kind of activity?
    9·1 answer
  • Thank you very much for your email. ...... was very interesting​
    15·1 answer
  • IN WHICH COUNTRY DO THEY LET YOU PLAY MINECRAFT IN SCHOOL?
    8·2 answers
  • Complete the statement below using the correct term.<br>Website managers use<br>every day​
    11·2 answers
  • Key Vocabulary:
    7·1 answer
  • True or False: A sequential search of a list assumes that the list elements are sorted in ascending order.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!